inversitron
Version:
Simple framework based on InversifyJS
36 lines (35 loc) • 1.48 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.app = void 0;
var colors_1 = require("colors");
var cors_1 = __importDefault(require("cors"));
var body_parser_1 = require("body-parser");
var inversify_express_utils_1 = require("inversify-express-utils");
var readConfigFile_1 = __importDefault(require("../cli/utils/readConfigFile"));
var app = function (container) { return function (a) {
var _a, _b;
var prod = readConfigFile_1.default().prod;
var host = process.env.H;
var port = (_a = process.env.PORT) !== null && _a !== void 0 ? _a : prod.port;
var rootPath = (_b = process.env.RP) !== null && _b !== void 0 ? _b : prod.rootPath;
var server = new inversify_express_utils_1.InversifyExpressServer(container, null, { rootPath: rootPath });
server.setConfig(function (app) {
app.use(cors_1.default({
origin: process.env.CO,
optionsSuccessStatus: 200
}));
app.use(body_parser_1.urlencoded({ extended: true }));
app.use(body_parser_1.json());
if (a) {
a(app);
}
});
var app = server.build();
app.listen(port, function () {
return console.log(colors_1.green('Server is now running on:'), colors_1.cyan(host + ":" + port + rootPath + "\n"));
});
}; };
exports.app = app;