-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added commented out support for API Gateway to Serverless config * Added a normalize response helper to support API Gateway * Tweaked API GW support for POST instead of GET Will now return the "Event type not supported" error if the httpMethod is a GET request, as body on GET is not standard practice.
- Loading branch information
1 parent
cd08176
commit 39626f3
Showing
4 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @typedef {import('aws-lambda').APIGatewayEvent} APIGatewayEvent | ||
* @typedef {import('aws-lambda').ScheduledEvent} ScheduledEvent | ||
* @typedef {import('aws-lambda').SNSEvent} SNSEvent | ||
* @typedef {import('aws-lambda').SQSEvent} SQSEvent | ||
*/ | ||
|
||
/** | ||
* @param {APIGatewayEvent|ScheduledEvent|SNSEvent|SQSEvent} event | ||
* @param response | ||
*/ | ||
|
||
const normalizedResponse = (event, response) => { | ||
if ("httpMethod" in event) { | ||
return { | ||
"statusCode": 200, | ||
"body": JSON.stringify(response), | ||
"isBase64Encoded": false | ||
}; | ||
} | ||
else { | ||
return response; | ||
} | ||
}; | ||
|
||
module.exports = normalizedResponse; |