@janiscommerce/sls-api-rest

5.0.0 • Public • Published

sls-api-rest

Build Status Coverage Status npm version

An integration handler for Serverless and JANIS Rest APIs

Installation

npm install @janiscommerce/sls-api-rest

Dependencies

This package only works properly with serverless-offline@5.9.0 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:

Readme

Keywords

none

Package Sidebar

Install

npm i @janiscommerce/sls-api-rest

Weekly Downloads

532

Version

5.0.0

License

ISC

Unpacked Size

9.62 kB

Total Files

5

Last publish

Collaborators

  • janiscommerce