2023-07-25 14:34:19 +02:00

39 lines
1017 B
TypeScript

import "module-alias/register";
import "reflect-metadata";
import { Container } from "typedi";
import ExpressServer from "@Common/system/ExpressServer";
import routes from "@App/index";
import cors from "cors";
import bodyParser from "body-parser";
import errorHandler from "@App/middlewares/ErrorHandler";
import { BackendVariables } from "@Common/config/variables/Variables";
import multer from "multer";
const storage = multer.memoryStorage();
(async () => {
try {
const variables = await Container.get(BackendVariables).validate();
const port = variables.APP_PORT;
const rootUrl = variables.APP_ROOT_URL;
const label = variables.APP_LABEL ?? "Unknown Service";
Container.get(ExpressServer).init({
label,
port: parseInt(port),
rootUrl,
middlwares: [
cors({ origin: "*" }),
multer({ storage: storage }).single("file"),
bodyParser.urlencoded({ extended: true }),
bodyParser.json(),
],
errorHandler,
});
routes.start();
} catch (e) {
console.error(e);
}
})();