Skip to content

Instantly share code, notes, and snippets.

@kingcody
Created May 18, 2015 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingcody/267a76394c6a4df1904d to your computer and use it in GitHub Desktop.
Save kingcody/267a76394c6a4df1904d to your computer and use it in GitHub Desktop.
Koa - seperate routers
var app = require('koa')();
app
.use(require('./router1').prefix('/route1').routes())
.use(require('./router2').prefix('/route2').routes());
app.listen(8000);
var router = new require('koa-router')();
router.get('/', function *(){
this.body = "ello world, router1";
});
module.exports = router;
var router = new require('koa-router')();
router.get('/', function *(){
this.body = "ello world, router2";
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment