@janiscommerce/sls-api-rest
v5.0.1
Published
An integration handler for Serverless and Janis Rest APIs
Downloads
1,648
Readme
sls-api-rest
An integration handler for Serverless and JANIS Rest APIs
Installation
npm install @janiscommerce/sls-api-rest
Dependencies
This package only works properly with [email protected] or greater
Usage
'use strict';
const { SlsApiRest } = require('@janiscommerce/sls-api-rest');
module.exports.handler = (...args) => SlsApiRest.handler(...args);
Function minimal configuration
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: