siren-enrouten
A Route configuration middleware for koa, and this is based on express-enrouten.
Usage
var koa = enrouten = ; var app = ;app;
Configuration
Please refer to express-enrouten, except that all middleware should be generators.
Note
If you want to mount the enrouten using middleware like koa-mount, you SHOULD set the mountpath
for enrouten, for example:
var app = mount = enrouten = ; var app = ;app;
Otherwise, when you use enrouten.url
, it will return an unmounted url.
routerOptions
The routerOptions
configuration option (optional) allows additional options to be
specified on each Router instance created by siren-enrouten
. Please refer to siren-router.
app;
Named Routes
For index
and directory
configurations there is also support for named routes.
When you use named routes by the passed siren-router instance, enrouten will fetch
the named routes out and you can get the named url by ctx.enrouten.url
or enrouten.url
.
For example:
var enrouten = ;app;
var enrouten = ; module { router; router;};
Controller Files
Please refer to express-enrouten, except that all middleware should be generators.
Tests
$ npm test
Coverage
$ npm run-script test-cov && open coverage/lcov-report/index.html