37 lines
1.1 KiB
TypeScript
Raw Normal View History

import { logger } from "./utils/logger";
logger.info("Starting up...");
2023-05-19 15:22:48 -03:00
import http from "http";
import https from "https";
import fs from "node:fs";
import { app } from "./app";
import { config, validateConfig } from "./services/configService";
import { connectDatabase } from "@/src/services/mongoService";
import { registerLogFileCreationListener } from "@/src/utils/logger";
2023-05-19 15:22:48 -03:00
registerLogFileCreationListener();
validateConfig();
2023-05-19 15:22:48 -03:00
void (async (): Promise<void> => {
await connectDatabase();
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")
};
2023-05-19 15:22:48 -03:00
http.createServer(app).listen(httpPort, () => {
logger.info("HTTP server started on port " + httpPort);
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)
);
});
});
})();