Skip to content

lambdaAdapter

lambdaAdapter<TEventMap>(router, options): (event, context) => Promise<APIGatewayProxyResult>

Defined in: lambda/src/index.ts:37

Creates an AWS Lambda handler for handling webhooks

The Lambda event body is used directly for signature verification. API Gateway provides the raw body as a string (or base64-encoded string), which is decoded and used for signature verification.

TEventMap extends Record<string, WebhookEvent>

WebhookRouter<TEventMap>

The WebhookRouter instance

LambdaAdapterOptions<TEventMap[keyof TEventMap]>

Adapter options including a verifier function

Lambda handler function

(event, context): Promise<APIGatewayProxyResult>

APIGatewayProxyEvent

Context

Promise<APIGatewayProxyResult>

import { lambdaAdapter } from '@kotodayori/lambda';
import { createStripeVerifier, StripeWebhookRouter } from '@kotodayori/stripe';
const router = new StripeWebhookRouter();
export const handler = lambdaAdapter(router, {
verifier: createStripeVerifier(stripe, process.env.STRIPE_WEBHOOK_SECRET!),
});