Files
myeasycms-v2/apps/web/app/api/db/webhook/route.ts
giancarlo 08c86102d8 Refactor code and improve error handling in authentication methods
This commit contains several changes including the removal of an unused onClick event handler in remove-member-dialog.tsx. It also includes an update to the POST handler in the Webhook route of the database API where the authentication property has been updated. Lastly, it also brings improvements in error handling and logging in various areas, such as e2e authentication tests and the mailbox utility.
2024-05-03 23:56:23 +07:00

27 lines
684 B
TypeScript

import { getDatabaseWebhookHandlerService } from '@kit/database-webhooks';
import { enhanceRouteHandler } from '@kit/next/routes';
/**
* @name POST
* @description POST handler for the webhook route that handles the webhook event
*/
export const POST = enhanceRouteHandler(
async ({ request }) => {
const service = getDatabaseWebhookHandlerService();
try {
// handle the webhook event
await service.handleWebhook(request);
// return a successful response
return new Response(null, { status: 200 });
} catch (error) {
// return an error response
return new Response(null, { status: 500 });
}
},
{
auth: false,
},
);