0.3.0 • Published 4 years ago

@tigojs/lambda-router v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

@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

0.3.0

4 years ago

0.1.2

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago