UNPKG

lambda-request-handler

Version:

An npm module that allows your Node.js web applications to be deployed as an AWS Lambda function and invoked in response to API Gateway, HTTP API, or Application Load Balancer requests.

26 lines (25 loc) 1.25 kB
import { RequestListener } from "http"; import { HapiListener } from "./handlers/hapiListener"; import * as apigw from "./types"; declare namespace handler { type APIGatewayEvent = apigw.APIGatewayEvent; type APIGatewayResponse = apigw.LambdaResponse; type LambdaResponse = apigw.LambdaResponse; type LambdaContext = apigw.LambdaContext; type APIGatewayEventHandler = (event: handler.APIGatewayEvent, context?: handler.LambdaContext) => Promise<handler.LambdaResponse>; } type PromiseFactory<A> = () => Promise<A>; interface Options { beforeDispatch?: (r: apigw.APIGatewayEvent) => Promise<apigw.APIGatewayEvent>; beforeReturn?: (r: apigw.LambdaResponse) => Promise<apigw.LambdaResponse>; onError?: (e: Error) => Promise<void>; } declare const handler: { (app: RequestListener, options?: Options): handler.APIGatewayEventHandler; deferred: (appFn: PromiseFactory<RequestListener>, options?: Options) => handler.APIGatewayEventHandler; HapiListener: typeof HapiListener; nestHandler: (nestApp: any) => Promise<any>; fastifyHandler: (fastifyBuilder: (options: object) => any) => (options: object) => Promise<RequestListener>; fastifyV4Handler: (app: any) => Promise<unknown>; }; export = handler;