Package Exports
- node-serverless-helpers
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-serverless-helpers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Node Serverless Helpers
Node Serverless Helpers is a package meant to make your life easier when developing lambda functions in NodeJS. It handles events seamlessly and adds useful defaults, helpers and functions to your project.
Documentation
The documentation can be found in the Wiki.
Usage
Install the package with npm or yarn.
npm install node-serverless-helpers
# or
yarn add node-serverless-helpers
Here is a sample working code.
// handler.js
'use strict';
const handle = require('node-serverless-helpers').handle;
module.exports.helloWorld = handle(async (event) => {
return 'hello lambda world!';
});
# serverless.yaml
service: hello-world
provider:
name: aws
runtime: nodejs8.10
region: us-east-1
functions:
hello:
handler: handler.helloWorld
events:
- http:
path: ''
method: get
The important part is the handle
function that does 3 things.
- Run the
init
function. You can register init handlers by calling theregister
function. - Run the front controller. Its job is to figure out what source the event comes from, and add useful middlewares to it.
- Run your function, and wrap the result to the expected format.
TODO
- Global logging system
- Implement more handlers
- Remove all console.logs