refactor(line): extract node webhook handler + shared verification

This commit is contained in:
Peter Steinberger
2026-02-15 00:59:32 +01:00
parent abf42abd41
commit 2493455f08
6 changed files with 310 additions and 124 deletions

15
src/line/webhook-utils.ts Normal file
View File

@@ -0,0 +1,15 @@
import type { WebhookRequestBody } from "@line/bot-sdk";
export function parseLineWebhookBody(rawBody: string): WebhookRequestBody | null {
try {
return JSON.parse(rawBody) as WebhookRequestBody;
} catch {
return null;
}
}
export function isLineWebhookVerificationRequest(
body: WebhookRequestBody | null | undefined,
): boolean {
return !!body && Array.isArray(body.events) && body.events.length === 0;
}