update webhook

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

@ -3,10 +3,18 @@ import { RestClientV5 } from 'bybit-api'
import { z } from 'zod' import { z } from 'zod'
export const POST = async ({ locals, request }) => { export const POST = async ({ locals, request }) => {
const type = request.headers.get('Content-Type')
console.log('type', type)
const text = await request.text() const text = await request.text()
console.log('text', text)
const body = JSON.parse(text) const body = JSON.parse(text)
console.log('text', body)
const flatSchema = z.object({ const flatSchema = z.object({
type: z.literal('Flat'), type: z.literal('Flat'),
key: z.string(), key: z.string(),
@ -40,6 +48,7 @@ export const POST = async ({ locals, request }) => {
const { key, secret, side, symbol } = form.data const { key, secret, side, symbol } = form.data
try {
let qty let qty
let takeProfit let takeProfit
let stopLoss let stopLoss
@ -50,7 +59,8 @@ export const POST = async ({ locals, request }) => {
stopLoss = form.data.stopLoss stopLoss = form.data.stopLoss
} else { } else {
qty = ( qty = (
(Number(form.data.entryPrice) * Number(form.data.qtyPercent)) / (Number(form.data.entryPrice) *
Number(form.data.qtyPercent)) /
100 100
).toString() ).toString()
takeProfit = ( takeProfit = (
@ -78,6 +88,9 @@ export const POST = async ({ locals, request }) => {
takeProfit, takeProfit,
stopLoss, stopLoss,
}) })
} catch (error) {
console.log('Error', error)
} finally {
return new Response() return new Response()
}
} }

Loading…
Cancel
Save