const requireDirectory=require('require-directory');
const Router=require('koa-router');
class InitManager {
static initCore(app){
InitManager.app=app;
InitManager.initLoadRouters();
}
static initLoadRouters() {
const apiDirectory=`${process.cwd()}/app/api`;//绝对路径,process.cwd()获取当前根目录文件夹的路径
requireDirectory(module, apiDirectory, { visit: whenLoadModule });
function whenLoadModule(obj) {
if (obj instanceof Router) {
InitManager.app.use(obj.routes());
}
}
// app.use(classic.routes())
}
}
module.exports=InitManager;