JSPM

lambda-actions

1.0.0-rc.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 63
    • Score
      100M100P100Q63720F
    • License MIT

    a tiny and unopinionated router for nodejs lambda functions

    Package Exports

    • lambda-actions
    • lambda-actions/dist/index.js

    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 (lambda-actions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    lambda action

    Installation

    $ npm i lambda-actions --save

    Usage

    /actions.ts

    export const sayHello = (payload) => {
      return { say: `Hello ${payload.names.join(' and ')}!` };
    };
    
    export const sayGoodbye = (payload) => {
      return { say: `Goodbye ${payload.name}` };
    };

    /index.ts

    import { sayHello, sayGoodbye } from './actions';
    
    export const async handler = (event) => {
    
      // init
      const router = new LambdaActions();
    
      // register actions
      router.action('say_hello', sayHello);
      // RegExp is also ok
      router.action(/say_(goodbye|ciao|pokedova)/, sayGoodbye);
    
      // fire an action
      return router.fire({
        action: event.action,
        payload: event.payload,
      });
    
    };