api-gateway-lambda-router
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

API Gateway Lambda Router

Use this router to manage your routes in AWS Lambda and API Gateway.

Usage

To be able to use this router create a route in API Gateway (API Type: HTTP API) wuth the path /{path+} and method ANY.

Usage example:

import { EventRouter } from 'api-gateway-lambda-router';

const router = new EventRouter({
  defaultHandler: async (requestData, response) => {
    response({
      status: 404,
      data: 'Not found :('
    })
  },
  routes: [
    {
      path: '/hi/:name',
      method: 'GET',
      handler: async (requestData, response) => {
        response({
          data: {
            hello: requestData.pathParameters.name  
          }
        })
      }
    },
  ]
});

export async function handler (event: any) {
  return await router.eventHandler(event);
}

Readme

Keywords

none

Package Sidebar

Install

npm i api-gateway-lambda-router

Weekly Downloads

16

Version

1.3.0

License

ISC

Unpacked Size

17.5 kB

Total Files

9

Last publish

Collaborators

  • dsilva2401