Refactor webhook handler service and update dependencies

Refactor to make database webhook handler service a function. This change introduces the function `getDatabaseWebhookHandlerService()` to return an instance of the service, allowing easier management of instances. Dependencies are updated as well, including bringing `react-i18next` to version 14.1.1(i18next@23.11.3) and `@react-email/components` to version 0.0.17 and others.
This commit is contained in:
giancarlo
2024-04-30 02:36:48 +07:00
parent faaa26c4e8
commit 14dee4f347
6 changed files with 199 additions and 248 deletions

View File

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