diff --git a/config.json.example b/config.json.example index 757d8e7a..fa7c3449 100644 --- a/config.json.example +++ b/config.json.example @@ -6,6 +6,8 @@ "__valid_levels": "fatal, error, warn, info, http, debug, trace" }, "myAddress": "localhost", + "httpPort": 80, + "httpsPort": 443, "autoCreateAccount": true, "skipStoryModeChoice": true, "skipTutorial": true, diff --git a/src/index.ts b/src/index.ts index 450a5be5..48e2de34 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,7 @@ import https from "https"; import fs from "node:fs"; import { app } from "./app"; import { logger } from "./utils/logger"; +import { config } from "./services/configService"; //const morgan = require("morgan"); //const bodyParser = require("body-parser"); @@ -12,9 +13,14 @@ const options = { passphrase: "123456" }; +const httpPort = config.httpPort || 80; +const httpsPort = config.httpsPort || 443; + // const server = http.createServer(app).listen(80); -http.createServer(app).listen(80, () => logger.info("cache server started on port 80")); -const server = https.createServer(options, app).listen(443, () => logger.info("game server started on port 443")); +http.createServer(app).listen(httpPort, () => logger.info("cache server started on port " + httpPort)); +const server = https + .createServer(options, app) + .listen(httpsPort, () => logger.info("game server started on port " + httpsPort)); // server.keepAliveTimeout = 60 * 1000 + 1000; // server.headersTimeout = 60 * 1000 + 2000; diff --git a/src/services/configService.ts b/src/services/configService.ts index 54d1e78d..a5787c30 100644 --- a/src/services/configService.ts +++ b/src/services/configService.ts @@ -4,6 +4,8 @@ interface IConfig { mongodbUrl: string; logger: ILoggerConfig; myAddress: string; + httpPort?: number; + httpsPort?: number; autoCreateAccount?: boolean; skipStoryModeChoice?: boolean; skipTutorial?: boolean;