Files
dvcp-node-service/src/rest/index.js

17 lines
484 B
JavaScript
Raw Normal View History

2022-03-29 15:04:07 +08:00
const {findFile} = require("../utils/fsUtils");
2023-01-18 12:08:51 +08:00
const chalk = require("chalk");
const log = console.log
2022-03-29 15:04:07 +08:00
module.exports = {
init: ins => {
2022-04-01 16:05:56 +08:00
return findFile('./src/rest', file => {
2022-03-29 15:04:07 +08:00
if (!/index\.js/.test(file)) {
2022-04-01 16:05:56 +08:00
let rest = require(file.replace(/src[\\\/]rest/, '.'))
2023-01-18 12:08:51 +08:00
log(`${chalk.bgBlue.black(" REST ")} ${rest.action}`)
2022-03-29 15:04:07 +08:00
if (rest.method == "post") {
ins.post(rest.action, (req, res) => rest.execute(req, res))
}
}
})
}
}