初始化

This commit is contained in:
robin
2022-08-02 19:21:03 +08:00
parent 73c1343060
commit b7e5ee5fec
27 changed files with 564 additions and 156 deletions
-4
View File
@@ -1,4 +0,0 @@
module.exports = {
path : "app/*/model/*.js",
prefix : "auto",//接口前缀
}
-27
View File
@@ -1,27 +0,0 @@
'use strict';
/**
* 加载模型到路由
* 加载app/api目录下的文件到路由
*/
const Router = require('koa-router')
const config = require("./config")
// 错误处理
module.exports = {
sort : 999, //排序
use : false, // 是否使用
loadFun: async (app, fun) => { // 自行定义中间件的加载方式,将覆盖默认加载方法
const router = await fun(app)
app.use(router.routes()).use(router.allowedMethods())
},
fun : async (app) => {
const router = new Router({ //设置前缀
prefix: config.prefix
});
let list = await app.load(config.path)
list.forEach(item => {
})
return router
}
}
+1 -2
View File
@@ -58,9 +58,8 @@ module.exports = {
})
})
//默认根路由
router.all('/', async (ctx, next) => {
ctx.body = app.res.success("ok")
ctx.status = 200
await next();