Skip to content

Commit a2a0ef8

Browse files
author
Dieter Luypaert
committed
[WIP] fix(#18): expose aws context
1 parent 72dcb85 commit a2a0ef8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Application, Context, MemoryRequest, MemoryResponse } from '@curveball/core';
22
import qs from 'querystring';
3-
import { AwsLambdaHandler, AwsRequest, AwsResponse } from './types';
3+
import { AwsContext, AwsLambdaHandler, AwsRequest, AwsResponse } from './types';
44
import { convertBody, convertHeaders } from './util';
55

66
export default function lambdaHandler(app: Application): AwsLambdaHandler {
@@ -14,7 +14,8 @@ export default function lambdaHandler(app: Application): AwsLambdaHandler {
1414
awsRequest.isBase64Encoded ? Buffer.from(awsRequest.body, 'base64') : awsRequest.body,
1515
);
1616
const response = new MemoryResponse();
17-
const context = new Context(request, response);
17+
const context = new Context(request, response) as AwsContext;
18+
context.aws = { context, event: awsRequest };
1819

1920
await app.handle(context);
2021

@@ -42,4 +43,3 @@ export default function lambdaHandler(app: Application): AwsLambdaHandler {
4243
};
4344

4445
}
45-

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Context } from '@curveball/core';
2+
13
export type KeyValue = {
24
[name: string]: string
35
};
@@ -6,6 +8,10 @@ export type KeyMultiValue = {
68
[name: string]: string[]
79
};
810

11+
export interface AwsContext extends Context {
12+
aws: { context: any, event: AwsRequest }
13+
}
14+
915
export type AwsRequest = {
1016
resource: string,
1117
path: string,

0 commit comments

Comments
 (0)