wendyhao-router-prefix
v1.0.0
Published
koa router prefix auto url
Downloads
1
Maintainers
Readme
auto Set the subordinate routing path to the file where the relative path;
Example: //this route file path D:\project\route\api\user\order
'use strict'; var Router = require('koa-router'); var autoPrefix = require('wendyhao-router-prefix'); var router = new Router(); router.prefix(autoPrefix('route', __dirname)); //'route' is 'D:\project\route'
//show:url:/api/user/day/order
router.get('/', (ctx) => { ctx.body = 'login ok !'; });
//show:url:/api/user/day/order/pass
router.get('/pass', (ctx) => { ctx.body = 'pass ok !'; }); module.exports = router.routes();
router.prefix(routerpath('route', __dirname));