youzanyun-devtool-worker
Version:
- web - ws - proxy
48 lines (47 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
require("./module-hack");
const path_1 = tslib_1.__importDefault(require("path"));
const spring4js_nodejs_1 = require("spring4js-nodejs");
const index_1 = tslib_1.__importDefault(require("web/server/index"));
const index_2 = tslib_1.__importDefault(require("web/proxy/index"));
const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
const lodash_1 = require("lodash");
process.on("SIGINT", function () {
process.exit();
});
process.on("uncaughtException", function (err) {
console.error(err);
});
process.on('unhandledRejection', (reason, p) => {
console.error("Unhandled Rejection at: Promise ", p, " reason: ", reason);
});
async function launch() {
let container = new spring4js_nodejs_1.Container();
let dirList = [
path_1.default.resolve(__dirname, 'controller'),
path_1.default.resolve(__dirname, 'service'),
path_1.default.resolve(__dirname, 'dao'),
];
for (let dir of dirList) {
let jsFileList = await fast_glob_1.default(['**/*.js'], {
cwd: dir
});
for (let jsFile of jsFileList) {
let obj = require(path_1.default.join(dir, jsFile));
if (!lodash_1.isObject(obj) || !lodash_1.isObject(obj.default)) {
continue;
}
let clazz = obj.default;
clazz.jsFile = jsFile;
container.registServiceClazz(clazz);
}
}
global.container = container;
let httpServer = new index_1.default({ container });
await httpServer.start();
let proxy = new index_2.default({ container });
await proxy.start();
}
launch();