improve: tell user that the WebUI is available (#631)

This commit is contained in:
Sainan 2024-12-23 22:48:16 +01:00 committed by GitHub
parent 45cb9c6da0
commit 063adb3519
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 22 deletions

View File

@ -13,11 +13,6 @@ import { customRouter } from "@/src/routes/custom";
import { dynamicController } from "@/src/routes/dynamic";
import { statsRouter } from "@/src/routes/stats";
import { webuiRouter } from "@/src/routes/webui";
import { connectDatabase } from "@/src/services/mongoService";
import { registerLogFileCreationListener } from "@/src/utils/logger";
void registerLogFileCreationListener();
void connectDatabase();
const app = express();

View File

@ -7,21 +7,29 @@ import https from "https";
import fs from "node:fs";
import { app } from "./app";
import { config } from "./services/configService";
//const morgan = require("morgan");
//const bodyParser = require("body-parser");
import { connectDatabase } from "@/src/services/mongoService";
import { registerLogFileCreationListener } from "@/src/utils/logger";
const options = {
registerLogFileCreationListener();
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")
};
};
const httpPort = config.httpPort || 80;
const httpsPort = config.httpsPort || 443;
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);
// const server = http.createServer(app).listen(80);
http.createServer(app).listen(httpPort, () => logger.info("HTTP server started on port " + httpPort));
const server = https.createServer(options, app);
server.listen(httpsPort, () => logger.info("HTTPS server started on port " + httpsPort));
// server.keepAliveTimeout = 60 * 1000 + 1000;
// server.headersTimeout = 60 * 1000 + 2000;
logger.info(
"Access the WebUI in your browser at http://localhost" + (httpPort == 80 ? "" : ":" + httpPort)
);
});
});
})();

View File

@ -8,7 +8,7 @@ if (url === undefined) {
throw new Error("MONGODB_URL not found. Make sure you have a .env file in the root of the project!");
}
const connectDatabase = async () => {
export const connectDatabase = async (): Promise<void> => {
try {
await mongoose.connect(`${url}`);
logger.info("Connected to MongoDB");
@ -18,5 +18,3 @@ const connectDatabase = async () => {
}
}
};
export { connectDatabase };