koa-router-factory
Factory for koa-router 7.x
- Crate koa-router with config
- Support nested routes
Installation
Install using npm:
npm install koa-router-factory
Example
Basic usage :
;; const IndexController = index: { thisbody = "index action"; } secondAction: { thisbody = "second action"; } const app = ;const router = ; app ;
Config keys
Key | Type | Description |
---|---|---|
url | String |
URL for the route |
controller | Object |
Object contains all actions needed. Is optional for child route. If not defined for child route, parent controller is used |
action | String |
If not specified, index action is used |
childs | Object |
Child routes definitions |
method | String |
get, post, put, delete, patch or all HTTP method. Default is get |
Context is binded to tha action call.
Tests
Run test using npm test
.
Run coverage using npm run coverage
.