feat: add EpicGames get FreeGames (#3196)

This commit is contained in:
Zyx-A
2019-10-12 18:39:35 +08:00
committed by DIYgod
parent 572e3dea2e
commit 6a7d45945e
5 changed files with 118 additions and 0 deletions

View File

@@ -1,6 +1,23 @@
const Router = require('koa-router');
const router = new Router();
// 遍历整个 routes 文件夹,导入模块路由 router.js 和 router-custom.js 文件
// 格式参考用例routes/epicgames/router.js
const RouterPath = require('require-all')({
dirname: __dirname + '/routes',
filter: /^.*router([-_]custom[s]?)?\.js$/,
});
// 将收集到的自定义模块路由进行合并
for (const project in RouterPath) {
for (const routerName in RouterPath[project]) {
const proRouter = RouterPath[project][routerName]();
proRouter.stack.forEach((nestedLayer) => {
router.stack.push(nestedLayer);
});
}
}
// index
router.get('/', require('./routes/index'));