XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

feat: add httpPort & httpsPort options (#226)

dea35fbd
Sainan <sainan@calamity.gg>
提交于

代码差异

3 个文件 +12 -2
Modified config.json.example +2 -0
@@ -6,6 +6,8 @@
6 6 "__valid_levels": "fatal, error, warn, info, http, debug, trace"
7 7 },
8 8 "myAddress": "localhost",
9 "httpPort": 80,
10 "httpsPort": 443,
9 11 "autoCreateAccount": true,
10 12 "skipStoryModeChoice": true,
11 13 "skipTutorial": true,
Modified src/index.ts +8 -2
@@ -3,6 +3,7 @@ import https from "https";
3 3 import fs from "node:fs";
4 4 import { app } from "./app";
5 5 import { logger } from "./utils/logger";
6 import { config } from "./services/configService";
6 7 //const morgan = require("morgan");
7 8 //const bodyParser = require("body-parser");
8 9
@@ -12,9 +13,14 @@ const options = {
12 13 passphrase: "123456"
13 14 };
14 15
16 const httpPort = config.httpPort || 80;
17 const httpsPort = config.httpsPort || 443;
18
15 19 // const server = http.createServer(app).listen(80);
16 http.createServer(app).listen(80, () => logger.info("cache server started on port 80"));
17 const server = https.createServer(options, app).listen(443, () => logger.info("game server started on port 443"));
20 http.createServer(app).listen(httpPort, () => logger.info("cache server started on port " + httpPort));
21 const server = https
22 .createServer(options, app)
23 .listen(httpsPort, () => logger.info("game server started on port " + httpsPort));
18 24
19 25 // server.keepAliveTimeout = 60 * 1000 + 1000;
20 26 // server.headersTimeout = 60 * 1000 + 2000;
Modified src/services/configService.ts +2 -0
@@ -4,6 +4,8 @@ interface IConfig {
4 4 mongodbUrl: string;
5 5 logger: ILoggerConfig;
6 6 myAddress: string;
7 httpPort?: number;
8 httpsPort?: number;
7 9 autoCreateAccount?: boolean;
8 10 skipStoryModeChoice?: boolean;
9 11 skipTutorial?: boolean;