Files
myeasycms-v2/apps/web/app/api/db/webhook/route.ts
giancarlo 4914a56460 Refactor webhook signature verification process
The signature verification process for webhooks has been abstracted. Instead of performing the check directly in the handleWebhook method, it has been moved to a separate service class: PostgresDatabaseWebhookVerifierService. This refactor improves modularity and enables extending or replacing the verification logic more comfortably. The WEBHOOK_SENDER_PROVIDER environment variable is used to determine which verifier service to use.
2024-04-18 21:03:36 +08:00

23 lines
535 B
TypeScript

import { DatabaseWebhookHandlerService } from '@kit/database-webhooks';
const service = new DatabaseWebhookHandlerService();
const response = (status: number) => new Response(null, { status });
/**
* @name POST
* @description POST handler for the webhook route that handles the webhook event
* @param request
* @constructor
*/
export async function POST(request: Request) {
try {
// handle the webhook event
await service.handleWebhook(request);
return response(200);
} catch {
return response(500);
}
}