2024-11-14 12:05:21 +01:00

42 lines
1.3 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();
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: 100 * 1024 * 1024 } }).single("file"), // 100MB limit
// Increase the body parser limits for large payloads (optional)
bodyParser.json({ limit: "100mb" }), // Increase JSON body size limit
bodyParser.urlencoded({ extended: true, limit: "100mb", parameterLimit: 50000 }), // Increase URL-encoded form limit
],
errorHandler,
});
routes.start();
} catch (e) {
console.error(e);
}
})();