koa-router-prefix
v1.0.4
Published
根据文件名自动生成路由前缀
Downloads
6
Readme
Koa Router Prefix
根据文件名自动生成路由前缀
Installation
$ npm i koa-router-auto --save
Example
const app = new Koa()
const path = require('path')
const routerPrefix = require('koa-router-prefix')
routerPrefix(app, {
dir: path.join(__dirname, './controller'),
})
// controller/user.js
module.exports = function userRouter(route) {
route.get('/name', function* () {
this.body = 'user name'
})
}
// $ curl locahost:8080/user/name
// user name