Skip to content

An integration handler for Serverless and JANIS Rest APIs

Notifications You must be signed in to change notification settings

janis-commerce/sls-api-rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

About

An integration handler for Serverless and JANIS Rest APIs

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •