make AWS API Gateway's Mapping Template testable
npm install api-gateway-mapping-template
simple.js:
var mappingTemplate = require('api-gateway-mapping-template')
var vtl = '$input.json(\'$.data\')';
var payload = '{"data": {"url": "https://github.com/ToQoz/api-gateway-mapping-template"}}';
var result = mappingTemplate({template: vtl, payload: payload})
console.dir(result);
$ node ./simple.js
'{"url":"https://github.com/ToQoz/api-gateway-mapping-template"}'
- ToQoz/api-gateway-localdev - simulate API Gateway + Lambda in your local.
- online checker - http://mapping-template-checker.toqoz.net
var mappingTemplate = require('api-gateway-mapping-template')
This function renders AWS API Gateway's Mapping Template by using given payload, params and context.
- Arguments
- parameters - required -
map
- template - required -
String|Buffer
- payload - required -
String|Buffer
- params -
map
- path -
map<String, String|Number|Boolean|null>
- querystring -
map<String, String|Number|Boolean|null>
- header -
map<String, String|Number|Boolean|null>
- path -
- context -
map
- indentity -
map<String, String>
- cognitoAuthenticationType -
String
- cognitoIdentityId -
String
- cognitoIdentityPoolId -
String
- sourceIp -
String
- user -
String
- userAgent -
String
- userArn -
String
- cognitoAuthenticationType -
- requestId -
String
- resourceId -
String
- resourcePath -
String
- stage -
String
- indentity -
- template - required -
- parameters - required -
- Return value
- rendered template -
String
- rendered template -