Sainan 2efe0df2f2
All checks were successful
Build / build (18) (push) Successful in 1m4s
Build / build (20) (push) Successful in 1m9s
Build / build (22) (push) Successful in 1m1s
Build Docker image / docker (push) Successful in 50s
chore: fix some eslint warnings (#1007)
Reviewed-on: #1007
2025-02-24 20:56:34 -08:00

47 lines
1.5 KiB
TypeScript

import { logger } from "./utils/logger";
logger.info("Starting up...");
import http from "http";
import https from "https";
import fs from "node:fs";
import { app } from "./app";
import { config, validateConfig } from "./services/configService";
import { registerLogFileCreationListener } from "@/src/utils/logger";
import mongoose from "mongoose";
registerLogFileCreationListener();
validateConfig();
mongoose
.connect(config.mongodbUrl)
.then(() => {
logger.info("Connected to MongoDB");
const httpPort = config.httpPort || 80;
const httpsPort = config.httpsPort || 443;
const options = {
key: fs.readFileSync("static/certs/key.pem"),
cert: fs.readFileSync("static/certs/cert.pem")
};
// eslint-disable-next-line @typescript-eslint/no-misused-promises
http.createServer(app).listen(httpPort, () => {
logger.info("HTTP server started on port " + httpPort);
// eslint-disable-next-line @typescript-eslint/no-misused-promises
https.createServer(options, app).listen(httpsPort, () => {
logger.info("HTTPS server started on port " + httpsPort);
logger.info(
"Access the WebUI in your browser at http://localhost" + (httpPort == 80 ? "" : ":" + httpPort)
);
});
});
})
.catch(error => {
if (error instanceof Error) {
logger.error(`Error connecting to MongoDB server: ${error.message}`);
}
process.exit(1);
});