store request in bybit webhook

master
TZGyn 7 months ago
parent a3c2f9cf00
commit 5cab269b18
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -2,6 +2,7 @@ import { pgTable } from 'drizzle-orm/pg-core'
export const bybit_logs = pgTable('bybit_logs', (t) => ({
status: t.varchar('status').$type<'success' | 'failed'>().notNull(),
data: t.json('data').notNull(),
request: t.json('request').notNull(),
response: t.json('response').notNull(),
createdAt: t.bigint('created_at', { mode: 'number' }).notNull(),
}))

@ -1,51 +1,6 @@
<script lang="ts">
let { data } = $props()
import * as Table from '$lib/components/ui/table/index.js'
const invoices = [
{
invoice: 'INV001',
paymentStatus: 'Paid',
totalAmount: '$250.00',
paymentMethod: 'Credit Card',
},
{
invoice: 'INV002',
paymentStatus: 'Pending',
totalAmount: '$150.00',
paymentMethod: 'PayPal',
},
{
invoice: 'INV003',
paymentStatus: 'Unpaid',
totalAmount: '$350.00',
paymentMethod: 'Bank Transfer',
},
{
invoice: 'INV004',
paymentStatus: 'Paid',
totalAmount: '$450.00',
paymentMethod: 'Credit Card',
},
{
invoice: 'INV005',
paymentStatus: 'Paid',
totalAmount: '$550.00',
paymentMethod: 'PayPal',
},
{
invoice: 'INV006',
paymentStatus: 'Pending',
totalAmount: '$200.00',
paymentMethod: 'Bank Transfer',
},
{
invoice: 'INV007',
paymentStatus: 'Unpaid',
totalAmount: '$300.00',
paymentMethod: 'Credit Card',
},
]
</script>
<Table.Root>
@ -53,7 +8,8 @@
<Table.Header>
<Table.Row>
<Table.Head class="w-[100px]">Status</Table.Head>
<Table.Head>Data</Table.Head>
<Table.Head>Request</Table.Head>
<Table.Head>Response</Table.Head>
<Table.Head class="text-right">Timestamp</Table.Head>
</Table.Row>
</Table.Header>
@ -61,7 +17,8 @@
{#each data.logs as log (log)}
<Table.Row>
<Table.Cell class="font-medium">{log.status}</Table.Cell>
<Table.Cell>{JSON.stringify(log.data)}</Table.Cell>
<Table.Cell>{JSON.stringify(log.request)}</Table.Cell>
<Table.Cell>{JSON.stringify(log.response)}</Table.Cell>
<Table.Cell class="text-right">
{new Date(log.createdAt)}
</Table.Cell>

@ -199,7 +199,8 @@ export const POST = async ({ locals, request }) => {
await db.insert(bybit_logs).values({
status: order.retCode === 0 ? 'success' : 'failed',
data: order,
request: form.data,
response: order,
createdAt: Date.now(),
})
return new Response()

Loading…
Cancel
Save