diff --git a/src/index.ts b/src/index.ts index d705f07..0eeecd5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ import { Application, Context, MemoryRequest, MemoryResponse } from '@curveball/core'; -import { APIGatewayProxyHandler, APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'; +import { Context as AwsContext, APIGatewayProxyHandler, APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'; import qs from 'querystring'; import { convertBody, convertHeaders } from './util'; export default function lambdaHandler(app: Application): APIGatewayProxyHandler { - return async (awsEvent: APIGatewayProxyEvent): Promise => { + return async (awsEvent:APIGatewayProxyEvent, awsContext: AwsContext): Promise => { const request = new MemoryRequest( awsEvent.httpMethod, @@ -14,7 +14,8 @@ export default function lambdaHandler(app: Application): APIGatewayProxyHandler awsEvent.isBase64Encoded ? Buffer.from(awsEvent.body ?? '', 'base64') : awsEvent.body, ); const response = new MemoryResponse(); - const context = new Context(request, response); + const context = new Context(request, response) ; + context.aws = { context: awsContext, event: awsEvent }; await app.handle(context); diff --git a/src/types.ts b/src/types.ts index a4a8769..c801d80 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,11 @@ +import { Context as AwsContext, APIGatewayProxyEvent } from 'aws-lambda' + export type KeyMultiValue = { [name: string]: string[] }; + +declare module "@curveball/core" { + interface Context { + aws?: { context: AwsContext, event: APIGatewayProxyEvent } + } +}