var koa = require('koa');
var router = require('koa-frouter');
var app = koa();
app.use(router(app, {
root: './router'
}));
app.listen(3000);
equal to:
var koa = require('koa');
var _ = require('koa-route');
var users = require('./router/users/*uid.js');
var month = require('./router/posts/month/*id.js');
var week = require('./router/posts/week/*id.js');
var day = require('./router/posts/day/*id.js');
var links = require('./router/links.js');
var index = require('./router/index.js');
var app = koa();
app.use(_.post('/users/:uid', users.post));
app.use(_.get('/posts/month/:id', month.get));
app.use(_.get('/posts/week/:id', week.get));
app.use(_.get('/posts/day/:id', day.get));
app.use(_.get('/links', links.get));
app.use(_.get('/', index.get));
app.use(_.get('/index', index.get));
app.listen(3000);
请发表评论