kr
Simple express-like router for koa and roo.
var kr = require('kr');
app.use(kr.get('/pets', authenticate, pets.list));
app.use(kr.get('/pets/:name', authenticate, pets.show));
Features
This repo is essentially a fork of koa-route, with two API differences:
- support for route middleware
- populates
this.params
Installation
$ npm install kr
Example
Contrived resource-oriented example:
var _ = ;var koa = ;var app = ; var db = tobi: name: 'tobi' species: 'ferret' loki: name: 'loki' species: 'ferret' jane: name: 'jane' species: 'ferret' ; { // authenticate or redirect next;} var pets = { var names = Object; thisbody = 'pets: ' + names; } { var name = thisparamsname; var pet = dbname; if !pet return this; thisbody = petname + ' is a ' + petspecies; }; app;app; app;console;
License
MIT