geonix 1.22.1 → 1.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/Service.js +2 -2
- package/src/Util.js +18 -0
- package/test/middleware.js +16 -14
package/index.d.ts
CHANGED
|
@@ -227,6 +227,7 @@ export function parseMultipart(req: Request, _options: any): Promise<{
|
|
|
227
227
|
}[]>;
|
|
228
228
|
export function tempFilename(): any;
|
|
229
229
|
export function randomSafeId(size?: number): string;
|
|
230
|
+
export function deepMerge(target: any, ...source: any[]): any;
|
|
230
231
|
export function sleep(delay: number): Promise<any>;
|
|
231
232
|
export function nextTick(): Promise<any>;
|
|
232
233
|
export function picoid(size?: number): any;
|
package/package.json
CHANGED
package/src/Service.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { connection } from "./Connection.js";
|
|
2
|
-
import { picoid, sleep, hash, getSecondsSinceMidnight, OverlayObject, GeonixVersion, getFirstItemFromAsyncIterable, getNetworkAddresses } from "./Util.js";
|
|
2
|
+
import { picoid, sleep, hash, getSecondsSinceMidnight, OverlayObject, GeonixVersion, getFirstItemFromAsyncIterable, getNetworkAddresses, deepMerge } from "./Util.js";
|
|
3
3
|
import { webserver } from "./WebServer.js";
|
|
4
4
|
import { createConnection } from "net";
|
|
5
5
|
import { EOL } from "os";
|
|
@@ -54,7 +54,7 @@ export class Service {
|
|
|
54
54
|
#options = defaultServiceOptions;
|
|
55
55
|
|
|
56
56
|
async #start(options = {}) {
|
|
57
|
-
this.#options = { ...this.#options, ...options };
|
|
57
|
+
this.#options = deepMerge(this.#options, options); // { ...this.#options, ...options };
|
|
58
58
|
|
|
59
59
|
await webserver.waitUntilReady();
|
|
60
60
|
await connection.waitUntilReady();
|
package/src/Util.js
CHANGED
|
@@ -383,4 +383,22 @@ export function randomSafeId(size = 12) {
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
return result;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export function deepMerge(target, ...source) {
|
|
389
|
+
for (const src of source) {
|
|
390
|
+
for (const key in src) {
|
|
391
|
+
if (src[key] instanceof Object) {
|
|
392
|
+
if (!target[key]) {
|
|
393
|
+
target[key] = {};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
deepMerge(target[key], src[key]);
|
|
397
|
+
} else {
|
|
398
|
+
target[key] = src[key];
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return target;
|
|
386
404
|
}
|
package/test/middleware.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { Router } from "express";
|
|
2
1
|
import { ServeStatic, Service } from "../exports.js";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
console.log("THIS:", this);
|
|
3
|
+
class First extends Service {
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
"GET /first"(req, res) {
|
|
6
|
+
res.end(JSON.stringify(req.cookies));
|
|
7
|
+
}
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
}
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
class Second extends Service {
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
"GET /second"(req, res) {
|
|
14
|
+
res.end(JSON.stringify(req.cookies));
|
|
15
15
|
}
|
|
16
|
+
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
class Third extends Service {
|
|
19
|
+
"GET /third"(req, res) {
|
|
20
|
+
res.end(JSON.stringify(req.cookies));
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
Third.start();
|
|
25
|
+
First.start({ middleware: { raw: true } });
|
|
26
|
+
Second.start();
|