node简易服务器完成
This commit is contained in:
16
rest/index.js
Normal file
16
rest/index.js
Normal 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("接口初始化完毕")
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user