feat: add httpPort & httpsPort options (#226)

This commit is contained in:
Sainan 2024-05-22 23:32:11 +02:00 committed by GitHub
parent 0b00c269e2
commit dea35fbd99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 2 deletions

View File

@ -6,6 +6,8 @@
"__valid_levels": "fatal, error, warn, info, http, debug, trace" "__valid_levels": "fatal, error, warn, info, http, debug, trace"
}, },
"myAddress": "localhost", "myAddress": "localhost",
"httpPort": 80,
"httpsPort": 443,
"autoCreateAccount": true, "autoCreateAccount": true,
"skipStoryModeChoice": true, "skipStoryModeChoice": true,
"skipTutorial": true, "skipTutorial": true,

View File

@ -3,6 +3,7 @@ import https from "https";
import fs from "node:fs"; import fs from "node:fs";
import { app } from "./app"; import { app } from "./app";
import { logger } from "./utils/logger"; import { logger } from "./utils/logger";
import { config } from "./services/configService";
//const morgan = require("morgan"); //const morgan = require("morgan");
//const bodyParser = require("body-parser"); //const bodyParser = require("body-parser");
@ -12,9 +13,14 @@ const options = {
passphrase: "123456" passphrase: "123456"
}; };
const httpPort = config.httpPort || 80;
const httpsPort = config.httpsPort || 443;
// const server = http.createServer(app).listen(80); // const server = http.createServer(app).listen(80);
http.createServer(app).listen(80, () => logger.info("cache server started on port 80")); http.createServer(app).listen(httpPort, () => logger.info("cache server started on port " + httpPort));
const server = https.createServer(options, app).listen(443, () => logger.info("game server started on port 443")); const server = https
.createServer(options, app)
.listen(httpsPort, () => logger.info("game server started on port " + httpsPort));
// server.keepAliveTimeout = 60 * 1000 + 1000; // server.keepAliveTimeout = 60 * 1000 + 1000;
// server.headersTimeout = 60 * 1000 + 2000; // server.headersTimeout = 60 * 1000 + 2000;

View File

@ -4,6 +4,8 @@ interface IConfig {
mongodbUrl: string; mongodbUrl: string;
logger: ILoggerConfig; logger: ILoggerConfig;
myAddress: string; myAddress: string;
httpPort?: number;
httpsPort?: number;
autoCreateAccount?: boolean; autoCreateAccount?: boolean;
skipStoryModeChoice?: boolean; skipStoryModeChoice?: boolean;
skipTutorial?: boolean; skipTutorial?: boolean;