Skip to content

Commit 29744a5

Browse files
Removed commented code and added version validation.
1 parent c68c2d4 commit 29744a5

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/lambda-wrapper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ const ApiGatewayHandler = (router: Middleware, onFinished: OnFinishedHandler) =>
3636
* @return {promise} Returns undefined if callback param is set. Return a promise if callback param is undefined.
3737
*/
3838
const handleApiGatewayEvent: APIGatewayProxyHandler | APIGatewayProxyHandlerV2 = function (
39-
event: (APIGatewayProxyEvent & { version: string }) | APIGatewayProxyEventV2,
39+
event: APIGatewayProxyEvent | APIGatewayProxyEventV2,
4040
context: any
4141
) {
4242
return new Promise<APIGatewayProxyResult>(resolve => {
4343
const req =
44-
event.version == '2.0'
45-
? new RequestV2(event as APIGatewayProxyEventV2)
44+
'version' in event && event.version == '2.0'
45+
? new RequestV2(event)
4646
: new Request(event as APIGatewayProxyEvent)
4747
const res = (req.res = new Response(req, async (err: any, out: any) => {
4848
if (err) {

src/request.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,6 @@ export class Request extends Readable {
7777
this.query = parse(queryParamsToStringify(event.multiValueQueryStringParameters), {}) as {
7878
[name: string]: string | string[]
7979
}
80-
// Object
81-
// .keys(event.multiValueQueryStringParameters || {})
82-
// .reduce((queryParams, key) => {
83-
// const value = event.multiValueQueryStringParameters![key] // cannot be null at this point
84-
// const _key = key.replace(/\[\]/, '')
85-
// queryParams[_key] = value!.length > 1 ? (value as string[]) : (value![0] as string)
86-
// return queryParams
87-
// }, {} as { [name: string]: string | string[] })
8880

8981
this.path = event.path || ''
9082
this.url = event.path

0 commit comments

Comments
 (0)