0.1.0 • Published 9 years ago
koater v0.1.0
Koater
Koater is a router for koa.
Still under heavy development, do not use it in production.
Installation
Not an npm for the moment. You can use via this git repository.
Usage
### Instantiate router:
let router = require('koater');
Add route
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.
Retrieve route
let myRoute = router.getByName('myRouteName')
Params:
- (string) : the name of the route
Return:
- route (Object): an object representing the route
Associate to Koa app
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');
Roadmap
- Add possibility to add middleware
- Unit tests
- Publish on npm
Author
Irwin Lourtet dev@lourtet.fr
0.1.0
9 years ago