update webhook to accept string

master
TZGyn 10 months ago
parent e6ccfb8113
commit 649fdfcab7
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -3,7 +3,9 @@ import { RestClientV5 } from 'bybit-api'
import { z } from 'zod'
export const POST = async ({ locals, request }) => {
const body = await request.json()
const text = await request.text()
const body = JSON.parse(text)
const flatSchema = z.object({
type: z.literal('Flat'),
@ -26,9 +28,7 @@ export const POST = async ({ locals, request }) => {
takeProfitPercent: z.string().optional(),
stopLossPercent: z.string().optional(),
})
const form = z
.discriminatedUnion('type', [flatSchema, percentSchema])
.safeParse(body)
const form = z.union([flatSchema, percentSchema]).safeParse(body)
if (!form.success) {
console.log(form.error)

Loading…
Cancel
Save