Socket
Book a DemoInstallSign in
Socket

node-serverless-helpers

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-serverless-helpers

Helpers to simplify nodejs code on FASS environments

latest
Source
npmnpm
Version
3.0.6
Version published
Maintainers
1
Created
Source

Node Serverless Helpers

build codecov dependencies

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 the register 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.

Debug

To print useful debug logs export NODE_SLS_HELPERS_DEBUG=*.

TODO

  • Global logging system
  • Implement more handlers
  • Remove all console.logs

Licence

ISC - Copyright 2018 Thomas Ruiz

Keywords

node

FAQs

Package last updated on 19 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts