aws-http-router
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

AWS Lambda Router

A simple router for AWS Lambda functions and Serverless framework built with TypeScript.

Basic Usage

import { Router } from '@bitalikrty/aws-lambda-router';

const router = new Router();
router.route({
  path: '/my-path',
  method: 'GET',
  handler: (event, context) => {
    return { success: true };
  };
});

Concat Routers

import { Router } from '@bitalikrty/aws-lambda-router';

const usersRouter = new Router('/car');
usersRouter.get('/{id}', event => getCar(event.pathParameters.id))

const todoRouter = new Router('/todo');
todoRouter.post('', event => addTodo(JSON.parse(event.body)))

const router = new Router();
router
  .concat(usersRouter)
  .concat(todoRouter);

Error handling

Documentation to do. You can use Boom errors or errorDeclartion for routes. See code.

Readme

Keywords

none

Package Sidebar

Install

npm i aws-http-router

Weekly Downloads

1

Version

1.3.0

License

MIT

Unpacked Size

21.2 kB

Total Files

23

Last publish

Collaborators

  • bitalikrty