serverless-aws-lambda
Version:
AWS Application Load Balancer and API Gateway - Lambda dev tool for Serverless. Allows Express synthax in handlers. Supports packaging, local invoking and offline ALB, APG, S3, SNS, SQS, DynamoDB Stream server mocking.
112 lines (111 loc) • 3.24 kB
TypeScript
import type { IncomingMessage, ServerResponse } from "http";
import type { LambdaEndpoint } from "../../../lib/parseEvents/endpoints";
import { CommonEventGenerator } from "./common";
interface CommonApgEvent {
body?: string;
queryStringParameters: {
[key: string]: string;
};
isBase64Encoded: boolean;
headers: {
[key: string]: any;
};
pathParameters?: {
[key: string]: any;
};
}
export type ApgHttpApiEvent = {
version: string;
routeKey: string;
rawPath: string;
rawQueryString: string;
cookies?: string[];
requestContext: {
accountId: string;
apiId: string;
domainName: string;
domainPrefix: string;
http: {
method: string;
path: string;
protocol: string;
sourceIp: string;
userAgent: string;
};
requestId: string;
routeKey: string;
stage: string;
time: string;
timeEpoch: number;
};
} & CommonApgEvent;
export type ApgHttpEvent = {
version?: string;
resource: string;
path: string;
httpMethod: string;
multiValueHeaders: {
[key: string]: any;
};
multiValueQueryStringParameters: {
[key: string]: any;
};
requestContext: {
accountId: string;
apiId: string;
domainName: string;
domainPrefix: string;
extendedRequestId: string;
httpMethod: string;
path: string;
protocol: string;
requestId: string;
requestTime: string;
requestTimeEpoch: number;
resourcePath: string;
stage: string;
};
} & CommonApgEvent;
export declare class ApgRequestHandler extends CommonEventGenerator {
#private;
res: ServerResponse;
mockEvent: LambdaEndpoint;
payload: ApgHttpApiEvent | ApgHttpEvent;
constructor({ res, req, body, mockEvent, multiValueHeaders, isBase64Encoded, lambdaName, parsedURL, requestId, }: {
res: ServerResponse;
req: IncomingMessage;
body: any;
mockEvent: LambdaEndpoint;
multiValueHeaders: any;
isBase64Encoded: boolean;
lambdaName: string;
parsedURL: URL;
requestId: string;
});
static skipHeaders: string[];
static createApgV2Event: ({ req, mockEvent, parsedURL, requestId, isBase64Encoded, body, }: {
req: IncomingMessage;
mockEvent: LambdaEndpoint;
isBase64Encoded: boolean;
parsedURL: URL;
body: any;
requestId: string;
}) => ApgHttpApiEvent;
static createApgV1Event: ({ req, mockEvent, parsedURL, lambdaName, isBase64Encoded, requestId, body, }: {
req: IncomingMessage;
mockEvent: LambdaEndpoint;
parsedURL: URL;
lambdaName: string;
isBase64Encoded: boolean;
multiValueHeaders: {
[key: string]: string[];
};
requestId: string;
body: any;
}) => ApgHttpEvent;
returnError: (err?: any) => true | ServerResponse;
sendV1Response: (output?: any) => void;
sendV2Response: (output?: any) => ServerResponse | undefined;
sendResponse: (output?: any) => void | ServerResponse;
}
export {};