Files
myeasycms-v2/apps/web/app/api/database/webhook/route.ts
giancarlo aa12ecd5a2 Refactor API code and simplify billing display
The code in the webhook API has been refactored to move the DatabaseWebhookHandlerService instance out of the POST function scope. Furthermore, the display of renewal plan details on the billing page has been simplified and certain parts deemed superfluous have been removed. Numerous types and interfaces in the database.types.ts file have also been corrected and formatted for consistency and improved readability.
2024-03-31 15:13:44 +08:00

21 lines
483 B
TypeScript

import { z } from 'zod';
import { DatabaseWebhookHandlerService } from '@kit/database-webhooks';
const webhooksSecret = z
.string({
description: `The secret used to verify the webhook signature`,
})
.min(1)
.parse(process.env.SUPABASE_DB_WEBHOOK_SECRET);
const service = new DatabaseWebhookHandlerService();
export async function POST(request: Request) {
await service.handleWebhook(request, webhooksSecret);
return new Response(null, {
status: 200,
});
}