返回提交历史
Modified
src/app.ts
+0
-5
Modified
src/index.ts
+22
-14
Modified
src/services/mongoService.ts
+1
-3
XFEstudio/SpaceNinjaServer
improve: tell user that the WebUI is available (#631)
063adb35
代码差异
3 个文件
+23
-22
@@ -13,11 +13,6 @@ import { customRouter } from "@/src/routes/custom";
13
13
import { dynamicController } from "@/src/routes/dynamic";
14
14
import { statsRouter } from "@/src/routes/stats";
15
15
import { webuiRouter } from "@/src/routes/webui";
16
import { connectDatabase } from "@/src/services/mongoService";
17
import { registerLogFileCreationListener } from "@/src/utils/logger";
18
19
void registerLogFileCreationListener();
20
void connectDatabase();
21
16
22
17
const app = express();
23
18
@@ -7,21 +7,29 @@ import https from "https";
7
7
import fs from "node:fs";
8
8
import { app } from "./app";
9
9
import { config } from "./services/configService";
10
//const morgan = require("morgan");
11
//const bodyParser = require("body-parser");
10
import { connectDatabase } from "@/src/services/mongoService";
11
import { registerLogFileCreationListener } from "@/src/utils/logger";
12
12
13
const options = {
14
key: fs.readFileSync("static/certs/key.pem"),
15
cert: fs.readFileSync("static/certs/cert.pem")
16
};
13
registerLogFileCreationListener();
17
14
18
const httpPort = config.httpPort || 80;
19
const httpsPort = config.httpsPort || 443;
15
void (async (): Promise<void> => {
16
await connectDatabase();
20
17
21
// const server = http.createServer(app).listen(80);
22
http.createServer(app).listen(httpPort, () => logger.info("HTTP server started on port " + httpPort));
23
const server = https.createServer(options, app);
24
server.listen(httpsPort, () => logger.info("HTTPS server started on port " + httpsPort));
18
const httpPort = config.httpPort || 80;
19
const httpsPort = config.httpsPort || 443;
20
const options = {
21
key: fs.readFileSync("static/certs/key.pem"),
22
cert: fs.readFileSync("static/certs/cert.pem")
23
};
25
24
26
// server.keepAliveTimeout = 60 * 1000 + 1000;
27
// server.headersTimeout = 60 * 1000 + 2000;
25
http.createServer(app).listen(httpPort, () => {
26
logger.info("HTTP server started on port " + httpPort);
27
https.createServer(options, app).listen(httpsPort, () => {
28
logger.info("HTTPS server started on port " + httpsPort);
29
30
logger.info(
31
"Access the WebUI in your browser at http://localhost" + (httpPort == 80 ? "" : ":" + httpPort)
32
);
33
});
34
});
35
})();
@@ -8,7 +8,7 @@ if (url === undefined) {
8
8
throw new Error("MONGODB_URL not found. Make sure you have a .env file in the root of the project!");
9
9
}
10
10
11
const connectDatabase = async () => {
11
export const connectDatabase = async (): Promise<void> => {
12
12
try {
13
13
await mongoose.connect(`${url}`);
14
14
logger.info("Connected to MongoDB");
@@ -18,5 +18,3 @@ const connectDatabase = async () => {
18
18
}
19
19
}
20
20
};
21
22
export { connectDatabase };