@tigojs/lambda-router

0.3.0 • Public • Published

@tigojs/lambda-router

This is a router helper for tigo lambda users, based on koa-tree-router.

Usage

Firstly, you should add it to the server via npm install.

Then you can use it like this in your lambda:

const Router = require('@tigojs/lambda-router');

const router = new Router();

// your function
async function myBusinessFunction(ctx, next) {
  // your code
}

// path is the relative path to your router.
router.get('/route', myBusinessFunction);

async function handleRequest(ctx) {
  // MUST HAVE THIS LINE, OHTERWISE THE ROUTER WILL NOT WORK!
  return router.route(ctx);
  // AND ALSO, YOU SHOULD REGISTER ALL YOUR ROUTES BEFORE YOU CALL THIS FUNCTION.
}

module.exports = handleRequest;

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @tigojs/lambda-router

Weekly Downloads

0

Version

0.3.0

License

MIT

Unpacked Size

3.45 kB

Total Files

3

Last publish

Collaborators

  • backrunner