Skip to content

ShaunEgan/lambda-event-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lambda Event Router

A super lightweight router for use inside of lambda functions. This is useful inside of lambda functions which handle multiple request types and paths.

Does not require the use of other libraries and does not transform the event and context objects in any way.

Installation

npm install --save lambda-event-router

Example

const router = require('lambda-event-router').router();

router.get('/greeting', (event, context) => {
  context.succeed({
    statusCode: 200,
    body: JSON.stringify({ message: "Hello world" })
  });
});

module.exports.handler = router.route;

Supported methods

Currently supported HTTP methods include:

  • get
  • post
  • patch
  • put
  • delete
  • head
  • trace
  • options