Implement error handling and adjust import paths

This commit introduces error handling in the 'database-webhook-handler.service.ts' to log and rethrow errors when processing webhooks. It also adjusts the import paths for ContentlayerClient and WordpressClient in 'create-cms-client.ts'. Method names in 'database-webhook-router.service.ts' have been updated for clarity.
This commit is contained in:
giancarlo
2024-04-02 16:03:11 +08:00
parent eb43059fda
commit 2dc2c6461e
3 changed files with 37 additions and 19 deletions

View File

@@ -36,16 +36,30 @@ export class DatabaseWebhookHandlerService {
// handle the webhook
const service = new DatabaseWebhookRouterService(client);
await service.handleWebhook(json);
try {
await service.handleWebhook(json);
Logger.info(
{
name: this.namespace,
table,
type,
},
'Webhook processed successfully',
);
Logger.info(
{
name: this.namespace,
table,
type,
},
'Webhook processed successfully',
);
} catch (error) {
Logger.error(
{
name: this.namespace,
table,
type,
error,
},
'Failed to process webhook',
);
throw error;
}
}
private assertSignatureIsAuthentic(request: Request, webhooksSecret: string) {