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: config refactoring (#219)

64b4523b
Sainan <sainan@calamity.gg>
提交于

代码差异

21 个文件 +64 -60
Modified .env.example +1 -12
@@ -1,15 +1,4 @@
1 MONGODB_URL='mongodb://127.0.0.1:27017/openWF'
2
3 #DOCKER ONLY
1 # Docker may need a .env file for the following settings:
4 2 DATABASE_PORT=27017
5 3 DATABASE_USERNAME=root
6 4 DATABASE_PASSWORD=database
7 #DOCKER ONLY END
8
9 # save logs to file
10 LOG_FILES=true
11 #possible log levels: { fatal: 0, error: 1, warn: 2, info: 3, http: 4, debug: 5, trace: 6 }
12 LOG_LEVEL=trace
13
14
15
Modified .github/workflows/build.yml +1 -0
@@ -15,4 +15,5 @@ jobs:
15 15 with:
16 16 node-version: "20.x"
17 17 - run: npm ci
18 - run: cp config.json.example config.json
18 19 - run: npm run build
Modified .gitignore +1 -0
@@ -2,6 +2,7 @@
2 2 /build
3 3
4 4 /.env
5 /config.json
5 6 /static/data/*.bin
6 7 yarn.lock
7 8 /tmp
Renamed config.json.example +7 -3
@@ -1,8 +1,12 @@
1 1 {
2 "mongodbUrl": "mongodb://127.0.0.1:27017/openWF",
3 "logger": {
4 "files": true,
5 "level": "trace",
6 "__valid_levels": "fatal, error, warn, info, http, debug, trace"
7 },
8 "myAddress": "localhost",
2 9 "autoCreateAccount": true,
3 "buildLabel": "2024.05.03.11.35/g98E42og3EdWxS0UueO+PQ",
4 "matchmakingBuildId": "6945333874579955227",
5 "version": "35.5.11",
6 10 "skipStoryModeChoice": true,
7 11 "skipTutorial": true,
8 12 "unlockAllScans": true,
Modified package-lock.json +0 -12
@@ -10,7 +10,6 @@
10 10 "license": "GNU",
11 11 "dependencies": {
12 12 "copyfiles": "^2.4.1",
13 "dotenv": "^16.1.3",
14 13 "express": "^5.0.0-beta.3",
15 14 "mongoose": "^8.1.1",
16 15 "warframe-items": "^1.1261.19",
@@ -1493,17 +1492,6 @@
1493 1492 "node": ">=6.0.0"
1494 1493 }
1495 1494 },
1496 "node_modules/dotenv": {
1497 "version": "16.1.3",
1498 "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.1.3.tgz",
1499 "integrity": "sha512-FYssxsmCTtKL72fGBSvb1K9dRz0/VZeWqFme/vSb7r7323x4CRaHu4LvQ5JG3+s6yt2YPbBrkpiEODktfyjI9A==",
1500 "engines": {
1501 "node": ">=12"
1502 },
1503 "funding": {
1504 "url": "https://github.com/motdotla/dotenv?sponsor=1"
1505 }
1506 },
1507 1495 "node_modules/dynamic-dedupe": {
1508 1496 "version": "0.3.0",
1509 1497 "resolved": "https://registry.npmjs.org/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz",
Modified package.json +0 -1
@@ -14,7 +14,6 @@
14 14 "license": "GNU",
15 15 "dependencies": {
16 16 "copyfiles": "^2.4.1",
17 "dotenv": "^16.1.3",
18 17 "express": "^5.0.0-beta.3",
19 18 "mongoose": "^8.1.1",
20 19 "warframe-items": "^1.1261.19",
Modified src/controllers/api/getCreditsController.ts +1 -1
@@ -1,5 +1,5 @@
1 1 import { RequestHandler } from "express";
2 import config from "@/config.json";
2 import { config } from "@/src/services/configService";
3 3 import { getInventory } from "@/src/services/inventoryService";
4 4 import { parseString } from "@/src/helpers/general";
5 5
Modified src/controllers/api/getShipController.ts +1 -1
@@ -1,5 +1,5 @@
1 1 import { RequestHandler } from "express";
2 import config from "@/config.json";
2 import { config } from "@/src/services/configService";
3 3 import allShipFeatures from "@/static/fixed_responses/allShipFeatures.json";
4 4 import { parseString } from "@/src/helpers/general";
5 5 import { getPersonalRooms } from "@/src/services/personalRoomsService";
Modified src/controllers/api/inventoryController.ts +1 -1
@@ -2,7 +2,7 @@
2 2 import { toInventoryResponse } from "@/src/helpers/inventoryHelpers";
3 3 import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
4 4 import { Request, RequestHandler, Response } from "express";
5 import config from "@/config.json";
5 import { config } from "@/src/services/configService";
6 6 import allMissions from "@/static/fixed_responses/allMissions.json";
7 7 import allQuestKeys from "@/static/fixed_responses/allQuestKeys.json";
8 8 import allShipDecorations from "@/static/fixed_responses/allShipDecorations.json";
Modified src/controllers/api/loginController.ts +11 -10
@@ -1,13 +1,14 @@
1 1 /* eslint-disable @typescript-eslint/no-unused-vars */
2 2 import { RequestHandler } from "express";
3 3
4 import config from "@/config.json";
4 import { config } from "@/src/services/configService";
5 import buildConfig from "@/static/data/buildConfig.json";
5 6
6 7 import { toLoginRequest } from "@/src/helpers/loginHelpers";
7 8 import { Account } from "@/src/models/loginModel";
8 9 import { createAccount, isCorrectPassword } from "@/src/services/loginService";
9 10 import { ILoginResponse } from "@/src/types/loginTypes";
10 import { DTLS, groups, HUB, IRC, Nonce, NRS, platformCDNs } from "@/static/fixed_responses/login_static";
11 import { DTLS, groups, HUB, Nonce, platformCDNs } from "@/static/fixed_responses/login_static";
11 12 import { logger } from "@/src/utils/logger";
12 13
13 14 // eslint-disable-next-line @typescript-eslint/no-misused-promises
@@ -39,12 +40,12 @@ const loginController: RequestHandler = async (request, response) => {
39 40 Groups: groups,
40 41 platformCDNs: platformCDNs,
41 42 Nonce: Nonce,
42 NRS: NRS,
43 NRS: [config.myAddress],
43 44 DTLS: DTLS,
44 IRC: IRC,
45 IRC: [config.myAddress],
45 46 HUB: HUB,
46 BuildLabel: config.buildLabel,
47 MatchmakingBuildId: config.matchmakingBuildId
47 BuildLabel: buildConfig.buildLabel,
48 MatchmakingBuildId: buildConfig.matchmakingBuildId
48 49 };
49 50
50 51 response.json(newLoginResponse);
@@ -68,12 +69,12 @@ const loginController: RequestHandler = async (request, response) => {
68 69 Groups: groups,
69 70 platformCDNs: platformCDNs,
70 71 Nonce: Nonce,
71 NRS: NRS,
72 NRS: [config.myAddress],
72 73 DTLS: DTLS,
73 IRC: IRC,
74 IRC: [config.myAddress],
74 75 HUB: HUB,
75 BuildLabel: config.buildLabel,
76 MatchmakingBuildId: config.matchmakingBuildId
76 BuildLabel: buildConfig.buildLabel,
77 MatchmakingBuildId: buildConfig.matchmakingBuildId
77 78 };
78 79
79 80 response.json(newLoginResponse);
Modified src/controllers/dynamic/worldStateController.ts +2 -2
@@ -1,11 +1,11 @@
1 1 import { RequestHandler } from "express";
2 2 import worldState from "@/static/fixed_responses/worldState.json";
3 import config from "@/config.json";
3 import buildConfig from "@/static/data/buildConfig.json";
4 4
5 5 const worldStateController: RequestHandler = (_req, res) => {
6 6 res.json({
7 7 ...worldState,
8 BuildLabel: config.buildLabel,
8 BuildLabel: buildConfig.buildLabel,
9 9 Time: Math.round(Date.now() / 1000)
10 10 });
11 11 };
Modified src/controllers/stats/viewController.ts +1 -1
@@ -1,7 +1,7 @@
1 1 import { RequestHandler } from "express";
2 2 import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
3 3 import { IStatsView } from "@/src/types/statTypes";
4 import config from "@/config.json";
4 import { config } from "@/src/services/configService";
5 5 import view from "@/static/fixed_responses/view.json";
6 6 import allScans from "@/static/fixed_responses/allScans.json";
7 7
Modified src/routes/cache.ts +2 -2
Added src/services/configService.ts +24 -0
Modified src/services/inventoryService.ts +1 -1
Modified src/services/mongoService.ts +2 -4
Modified src/utils/logger.ts +3 -5
Deleted static/data/.gitkeep +0 -0
Added static/data/buildConfig.json +5 -0
Deleted static/data/items.ts +0 -0
Modified static/fixed_responses/login_static.ts +0 -4