42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
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";
|
|
import "../sentry.config";
|
|
|
|
const storage = multer.memoryStorage();
|
|
|
|
(async () => {
|
|
try {
|
|
const variables = await Container.get(BackendVariables).validate();
|
|
console.log(variables);
|
|
|
|
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, limits: { fileSize: 32000000 } }).single("file"), //32 MB maximum
|
|
bodyParser.json({ limit: "35mb" }),
|
|
bodyParser.urlencoded({ extended: true, limit: "35mb", parameterLimit: 50000 }),
|
|
],
|
|
errorHandler,
|
|
});
|
|
|
|
routes.start();
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
})();
|