Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@everestate/serverless-router-event

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@everestate/serverless-router-event

Serverless Router plugin to handle events at AWS λ

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

@everestate/serverless-router-event

Serverless Router plugin to handle events at AWS λ

Installation

npm install @everestate/serverless-router @everestate/serverless-router-event --save

Usage

Each routing subject (event object) is expected to to include at least:

  • emitter (string) - who published event
  • subject (string) - what's the domain of event
  • action (string) - what's happen in scope of the domain
  • version (string) - event payload version

The routing path looks like "emitter:subject:action:version".

It's fine to use mask to match any part: "emitter:subject:*:version".

const Router = require('@everestate/serverless-router');
const { Event } = require('@everestate/serverless-router-event');

function dispatch(event) {
  const router = new Router([Event]);

  router.event
    .on('steam:listing:created:1', (ctx, event) => ({ ctx, event }))
    .on('steam:listing:updated:1', (ctx, event) => ({ ctx, event }))
    .on('steam:listing:*:1', (ctx, event) => ({ ctx, event }));

  router.mismatch(() => Promise.reject(new Error('Boom!')));

  return router.dispatch(event);
}

function myLambdaHandler(event, context, callback) {
  return dispatch(event)
    .then(result => callback(null, result))
    .catch(error => callback(error));
}

Keywords

FAQs

Package last updated on 07 Aug 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc