Skip to content

Commit

Permalink
Add Support for multiValueQueryStringParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sternetj committed Nov 4, 2024
1 parent f4f2fd2 commit 9059383
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/adapters/helpers/lambdaEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => {
querystringWithArraySupport,
);
const params = Object.assign({}, parts.query, config.params);
const multiValueQueryStringParameters: Record<string, any> = { ...params };

Object.keys(multiValueQueryStringParameters).forEach((key) => {
if (!Array.isArray(multiValueQueryStringParameters[key])) {
delete multiValueQueryStringParameters[key];
}
});

const httpMethod = (config.method as string).toUpperCase();
const requestTime = new Date();
Expand Down Expand Up @@ -64,7 +71,10 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => {
userArn: null,
},
},
multiValueQueryStringParameters: null,
multiValueQueryStringParameters:
Object.keys(multiValueQueryStringParameters).length > 0
? multiValueQueryStringParameters
: null,
};

if (Buffer.isBuffer(event.body)) {
Expand Down
8 changes: 8 additions & 0 deletions test/lambda-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ test('Can parse URLs with duplicate parameters', () => {
],
pageSize: '25',
},
multiValueQueryStringParameters: {
_tag: [
'http://lifeomic.com/fhir/questionnaire-type|survey-form',
'http://lifeomic.com/fhir/dataset|0bb18fef-4e2d-4b91-a623-09527265a8b3',
'http://lifeomic.com/fhir/primary|0343bfcf-4e2d-4b91-a623-095272783bf3',
],
},
}));
assertRequestId(result);
});
Expand All @@ -55,6 +62,7 @@ test('Can parse URLs without duplicates', () => {
pageSize: '25',
test: 'diffValue',
},
multiValueQueryStringParameters: null,
}));
assertRequestId(result);
});
Expand Down

0 comments on commit 9059383

Please sign in to comment.