geonix 1.22.1 → 1.22.3

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 CHANGED
@@ -213,6 +213,7 @@ type ServiceOptions = {
213
213
  export function parseURL(url: string): any;
214
214
  export function getFirstItemFromAsyncIterable(asyncIterable: any): Promise<any>;
215
215
  export function getNetworkAddresses(): any[];
216
+ export function isIterable(obj: any): any;
216
217
  /**
217
218
  *
218
219
  *
@@ -227,6 +228,7 @@ export function parseMultipart(req: Request, _options: any): Promise<{
227
228
  }[]>;
228
229
  export function tempFilename(): any;
229
230
  export function randomSafeId(size?: number): string;
231
+ export function deepMerge(target: any, ...source: any[]): any;
230
232
  export function sleep(delay: number): Promise<any>;
231
233
  export function nextTick(): Promise<any>;
232
234
  export function picoid(size?: number): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonix",
3
- "version": "1.22.1",
3
+ "version": "1.22.3",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "bin": {
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
@@ -241,6 +241,10 @@ export function getNetworkAddresses() {
241
241
  return list;
242
242
  }
243
243
 
244
+ export function isIterable(obj) {
245
+ return obj && (typeof obj[Symbol.iterator] === "function" || typeof obj[Symbol.asyncIterator] === "function");
246
+ }
247
+
244
248
  /**
245
249
  *
246
250
  *
@@ -263,7 +267,7 @@ export async function parseMultipart(req, _options) {
263
267
  let stream = req;
264
268
 
265
269
  // if body is present, create a stream from it and use memory
266
- if (req.body) {
270
+ if (req.body && isIterable(req.body)) {
267
271
  stream = Readable.from(req.body);
268
272
  options.useMemory = true;
269
273
  }
@@ -383,4 +387,22 @@ export function randomSafeId(size = 12) {
383
387
  }
384
388
 
385
389
  return result;
390
+ }
391
+
392
+ export function deepMerge(target, ...source) {
393
+ for (const src of source) {
394
+ for (const key in src) {
395
+ if (src[key] instanceof Object) {
396
+ if (!target[key]) {
397
+ target[key] = {};
398
+ }
399
+
400
+ deepMerge(target[key], src[key]);
401
+ } else {
402
+ target[key] = src[key];
403
+ }
404
+ }
405
+ }
406
+
407
+ return target;
386
408
  }