Improve reusability of the webhook handler to allow converting the route to a Pages Router API Route. (#110)

This commit is contained in:
Giancarlo Buomprisco
2025-02-04 08:46:52 +07:00
committed by GitHub
parent 2a157e8baa
commit fcdae7aa65
4 changed files with 23 additions and 15 deletions

View File

@@ -10,8 +10,19 @@ export const POST = enhanceRouteHandler(
const service = getDatabaseWebhookHandlerService();
try {
const signature = request.headers.get('X-Supabase-Event-Signature');
if (!signature) {
return new Response('Missing signature', { status: 400 });
}
const body = await request.clone().json();
// handle the webhook event
await service.handleWebhook(request);
await service.handleWebhook({
body,
signature,
});
// return a successful response
return new Response(null, { status: 200 });