Koater is a router for koa.
Still under heavy development, do not use it in production.
npm install koater
### Instantiate router:
let router = require('koater');
router.use({name, path, method, fn})
Params:
- name (string) : name of the route (not mandatory). It is used to retreive the route by its name.
- path (string) : path of the route (eg /users )
- method (string) : HTTP method (GET, POST, PUT, ...)
- fn (function) : function used to handle the request. The this variable is the Koa one.
let myRoute = router.getByName('myRouteName')
Params:
- (string) : the name of the route
Return:
- route (Object): an object representing the route
let router = require('koater');
let koa = require('koa');
// Instantiate koa app
let app = koa();
... add routes to the router
app.use(router.routes());
app.listen('3000');
- Add possibility to add middleware
- Unit tests
- Publish on npm
Irwin Lourtet [email protected]