自动路由加载器
参数
homePath
必填
在req.path === ' ' || req.path === '/' 时跳转的路径
controllerPath
必填
路由controller路径
controllerFilePostfix
选填
controller文件的后缀
默认为'.controller'
Test.controller.js
测试
npm run test
配置
const autoLoader = require('express-autoload-route'); app.use('/', autoLoader({ controllerPath: path.join(__dirname, './controller') }));
转换
/home-one/show-index || \/ /controller/HomeOne.controller.js class HomeOne{ constructor({req, res}) { this.req = req; this.res = res; } showIndexActive() { this.res.send('ok'); } }