api-gateway-payload-parse
Utility function for easier parsing of the AWS API-Gateway built-in mapping template functions, like input.params()
.
Overview
By default, a mapping template like:
Will actually send it wrapped from Velocity like:
Instead of making complex mapping templates, this module remaps:
"{fields=id, anotherKey=aParam%2CanotherParam}"
to a javascript object:
{
fields: "id"
anotherKey: "aParam,anotherParam"
}
Install
$ npm install --save api-gateway-payload-parse
Usage
Create an integration request mapping template utilizing mapping variables provided by API Gateway. Or use the example above in overview
A full list is available here: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
// assuming a mapping template of:// { "query-params": "$input.params().querystring" }// which would make a application/json payload of:// {"query-params": "{fields=id, anotherKey=aParam%2CanotherParam}"} var payloadParse = ; exports { var query_string = ; context;};