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:
@@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user