17 lines
484 B
JavaScript
17 lines
484 B
JavaScript
const {findFile} = require("../utils/fsUtils");
|
|
const chalk = require("chalk");
|
|
const log = console.log
|
|
module.exports = {
|
|
init: ins => {
|
|
return findFile('./src/rest', file => {
|
|
if (!/index\.js/.test(file)) {
|
|
let rest = require(file.replace(/src[\\\/]rest/, '.'))
|
|
log(`${chalk.bgBlue.black(" REST ")} ${rest.action}`)
|
|
if (rest.method == "post") {
|
|
ins.post(rest.action, (req, res) => rest.execute(req, res))
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|