node简易服务器完成

This commit is contained in:
aixianling
2022-03-29 15:04:07 +08:00
parent 0905e9263c
commit d48be5b91f
8 changed files with 120 additions and 13 deletions

16
rest/index.js Normal file
View File

@@ -0,0 +1,16 @@
const {findFile} = require("../utils/fsUtils");
module.exports = {
init: ins => {
return findFile('./rest', file => {
if (!/index\.js/.test(file)) {
let rest = require(file.replace(/rest/, '.'))
console.log(`初始化接口...${rest.action}`)
if (rest.method == "post") {
ins.post(rest.action, (req, res) => rest.execute(req, res))
}
}
}).then(() => {
console.log("接口初始化完毕")
})
}
}