An integration handler for Serverless and JANIS Rest APIs
npm install @janiscommerce/sls-api-rest
This package only works properly with serverless-offline@5.9.0 or greater
'use strict';
const { SlsApiRest } = require('@janiscommerce/sls-api-rest');
module.exports.handler = (...args) => SlsApiRest.handler(...args);
functions:
handler: path/to/generic.handler
package:
include:
- path/to/my/api/get.js
events:
- http:
integration: lambda
path: /some-entity/{entityId}
method: GET
request:
parameters:
paths:
entityId: true
# Some velocity template that includes this properties:
# - headers
# - method
# - query
# - body
# - requestPath
# Native support for this template en Serverless Framework was suggested in https://github.com/serverless/serverless/issues/6364
# Still needed to work with serverless-offline
template: ${file(./serverless/functions/subtemplates/lambda-request-with-path.yml)}
# The response configuration to properly format body and headers + Error handling
response: ${file(./serverless/functions/subtemplates/lambda-response-with-cors.yml)}
# This is for serverless-offline only, because it doesn't use the `response` property (yet)
responses: ${file(./serverless/functions/subtemplates/lambda-serverless-offline-responses.yml)}
Sample subtemplates can be found here: