返回提交历史
Modified
CONTRIBUTING.md
+1
-1
Modified
README.md
+1
-0
Modified
UPDATE AND START SERVER.bat
+1
-0
Modified
UPDATE AND START SERVER.sh
+1
-0
Modified
package-lock.json
+469
-112
Modified
package.json
+1
-0
Modified
src/index.ts
+19
-1
XFEstudio/XFESpaceNinjaServer
feat: support file:// for mongodbUrl (#3717)
E.g. `file://./db-data` for a "db-data" folder relative to the working directory. If specified, a MongoDB server executable is downloaded to run alongside SNS. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3717 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
0b960088
代码差异
7 个文件
+493
-114
@@ -6,7 +6,7 @@ Use `npm i` or `npm ci` to install all dependencies, including dev dependencies.
6
6
7
7
### Development Process
8
8
9
Auto reloading is supported for server and WebUI development. Simply use `npm run dev` or `npm run dev:bun` to start the server and edit away.
9
Auto reloading is supported for server and WebUI development. Simply use `npm run dev` or `bun dev:bun` to start the server and edit away.
10
10
11
11
### Testing
12
12
@@ -13,6 +13,7 @@ To get an idea of what functionality you can expect to be missing [have a look t
13
13
SpaceNinjaServer requires a `config.json`. To set it up, you can copy the [config-vanilla.json](config-vanilla.json), which has most cheats disabled.
14
14
15
15
- `skipTutorial` affects only newly created accounts, so you may wish to change it before logging in for the first time.
16
- `mongodbUrl` can be a `mongodb://`, `mongodb+srv://` or `file://` URI.
16
17
- `logger.level` can be `fatal`, `error`, `warn`, `info`, `http`, `debug`, or `trace`.
17
18
- `bindAddress`, `httpPort`, `httpsPort` are related to how SpaceNinjaServer is reached on the network. Under Docker, these options are unchangable; modify your `docker-compose.yml`, instead.
18
19
- `ircExecutable` and `hubExecutable` can be provided with relative paths to executables which will be ran as child processes of SpaceNinjaServer.
@@ -3,6 +3,7 @@
3
3
echo Updating SpaceNinjaServer...
4
4
git fetch --prune
5
5
if %errorlevel% == 0 (
6
git restore package-lock.json
6
7
git stash
7
8
git checkout -f origin/main
8
9
@@ -3,6 +3,7 @@
3
3
echo "Updating SpaceNinjaServer..."
4
4
git fetch --prune
5
5
if [ $? -eq 0 ]; then
6
git restore package-lock.json
6
7
git stash
7
8
git checkout -f origin/main
8
9
@@ -30,6 +30,7 @@
30
30
"express": "^5",
31
31
"google-auth-library": "^10.5.0",
32
32
"json-with-bigint": "^3.4.4",
33
"mongodb-memory-server-core": "^11.0.1",
33
34
"mongoose": "^8.11.0",
34
35
"morgan": "^1.10.0",
35
36
"ncp": "^2.0.0",
@@ -25,6 +25,7 @@ import { startWebServer } from "./services/webService.ts";
25
25
import { validateConfig } from "./services/configWatcherService.ts";
26
26
import { updateWorldStateCollections } from "./services/worldStateService.ts";
27
27
import { repoDir } from "./helpers/pathHelper.ts";
28
import { MongoMemoryServer } from "mongodb-memory-server-core";
28
29
29
30
JSON.stringify = JSONStringify; // Patch JSON.stringify to work flawlessly with Bigints.
30
31
@@ -36,8 +37,25 @@ fs.readFile(path.join(repoDir, "BUILD_DATE"), "utf-8", (err, data) => {
36
37
}
37
38
});
38
39
40
let mongodUri = config.mongodbUrl;
41
if (mongodUri.startsWith("file://")) {
42
let dataDir = path.resolve(mongodUri.substring("file://".length));
43
if (dataDir.substring(0, 1) == "/" && process.platform == "win32") {
44
dataDir = dataDir.substring(1); // Absolute path on Windows must not start with /
45
}
46
fs.mkdirSync(dataDir, { recursive: true });
47
const mongod = await MongoMemoryServer.create({
48
instance: {
49
dbPath: dataDir
50
}
51
});
52
mongodUri = mongod.getUri();
53
logger.debug(`MongoDB server running at ${mongodUri}`);
54
mongodUri += "openWF";
55
}
56
39
57
mongoose
40
.connect(config.mongodbUrl)
58
.connect(mongodUri)
41
59
.then(() => {
42
60
logger.info("Connected to MongoDB");
43
61
syncConfigWithDatabase();