ptSend/router/config.js

45 lines
896 B
JavaScript

const Router = require("koa-router")
const config = require("../util/config/config")
const router = new Router({
prefix: "/config"
})
/**
* 获取配置文件接口
*/
router.get('/getConfig', async (ctx) => {
let json = config.getConfig();
const b = json === '{}'
ctx.body = {
code: b ? -1 : 0,
msg: b ? 'error' : "ok",
data: json
}
})
/**
* 设置配置文件接口
*/
router.post('/setConfig', async (ctx) => {
let body = ctx.request.body;
console.info(body)
// if (body === "") {
// ctx.body = {
// code: -1,
// msg: "提交内容不能为空"
// }
// return
// }
//
// let b = config.setConfig(body);
// console.info(b)
// ctx.body = {
// code: b ? 0 : -1,
// msg: b ? 'ok' : "error",
// data: null
// }
})
module.exports = router