|
| 1 | +import { Context } from "aws-lambda"; |
| 2 | +import { FastifyInstance, LightMyRequestResponse } from "fastify"; |
| 3 | + |
| 4 | +type AwsLambdaFastify = typeof awsLambdaFastify |
| 5 | + |
| 6 | +declare namespace awsLambdaFastify { |
| 7 | + export interface LambdaFastifyOptions { |
| 8 | + binaryMimeTypes?: string[]; |
| 9 | + callbackWaitsForEmptyEventLoop?: boolean; |
| 10 | + serializeLambdaArguments?: boolean; |
| 11 | + decorateRequest?: boolean; |
| 12 | + decorationPropertyName?: string; |
| 13 | + enforceBase64?: (response: LightMyRequestResponse) => boolean; |
| 14 | + } |
| 15 | + |
| 16 | + export interface LambdaResponse { |
| 17 | + statusCode: number; |
| 18 | + body: string; |
| 19 | + headers: Record<string, string>; |
| 20 | + isBase64Encoded: boolean; |
| 21 | + cookies?: string[] |
| 22 | + } |
| 23 | + |
| 24 | + export type PromiseHandler<TEvent = any, TResult = LambdaResponse> = ( |
| 25 | + event: TEvent, |
| 26 | + context: Context |
| 27 | + ) => Promise<TResult>; |
| 28 | + |
| 29 | + export type CallbackHandler<TEvent = any, TResult = LambdaResponse> = ( |
| 30 | + event: TEvent, |
| 31 | + context: Context, |
| 32 | + callback: (err?: Error, result?: TResult) => void |
| 33 | + ) => void; |
| 34 | + |
| 35 | + export const awsLambdaFastify: AwsLambdaFastify |
| 36 | + export { awsLambdaFastify as default } |
| 37 | +} |
| 38 | + |
| 39 | +declare function awsLambdaFastify<TEvent, TResult = awsLambdaFastify.LambdaResponse>( |
| 40 | + app: FastifyInstance, |
| 41 | + options?: awsLambdaFastify.LambdaFastifyOptions |
| 42 | +): awsLambdaFastify.PromiseHandler<TEvent, TResult>; |
| 43 | + |
| 44 | +declare function awsLambdaFastify<TEvent, TResult = awsLambdaFastify.LambdaResponse>( |
| 45 | + app: FastifyInstance, |
| 46 | + options?: awsLambdaFastify.LambdaFastifyOptions |
| 47 | +): awsLambdaFastify.CallbackHandler<TEvent, TResult>; |
| 48 | + |
| 49 | +export = awsLambdaFastify |
0 commit comments