Kind: Interface
Source: src/adapter/aws-lambda/handler.ts
Part of: Adapter
APIGatewayProxyEvent describes the request payload passed from Amazon API Gateway to an AWS Lambda handler. It contains HTTP request data, headers, query parameters, body encoding details, route information, and API Gateway request context.
Properties
| Property | Type |
|---|---|
version | string |
httpMethod | string |
headers | `Record<string, string |
multiValueHeaders | { [headerKey: string]: string[] } |
path | string |
body | `string |
isBase64Encoded | boolean |
queryStringParameters | `Record<string, string |
requestContext | ApiGatewayRequestContext |
resource | string |
multiValueQueryStringParameters | { [parameterKey: string]: string[] } |
pathParameters | Record<string, string> |
stageVariables | Record<string, string> |
Diagram
mermaidgraph LR APIGateway[API Gateway] --> Event[APIGatewayProxyEvent] Event --> Method[httpMethod] Event --> Route[path and resource] Event --> Headers[headers and multiValueHeaders] Event --> Query[queryStringParameters] Event --> Body[body and isBase64Encoded] Event --> Context[requestContext] Event --> Lambda[AWS Lambda Handler]
Usage
tsimport type { APIGatewayProxyEvent } from "./adapter/aws-lambda/handler";
export function readRequest(event: APIGatewayProxyEvent) {
const body =
event.body === null
? undefined
: event.isBase64Encoded
? Buffer.from(event.body, "base64").toString("utf8")
: event.body;
return {
method: event.httpMethod,
path: event.path,
contentType: event.headers["content-type"],
query: event.queryStringParameters,
body,
requestContext: event.requestContext,
};
}
AI Coding Instructions
- Treat
bodyas nullable and checkisBase64Encodedbefore reading or parsing its contents. - Read single-value headers from
headers; preserve repeated header values frommultiValueHeaders. - Handle missing query string and header values because their record values may be
undefined. - Pass
requestContextthrough to logging, tracing, or authorization code without assuming fields not defined byApiGatewayRequestContext.
Was this page helpful?