xypriss 4.3.6 → 4.4.1

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.
@@ -0,0 +1,600 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * XyPriss System Variables Class
5
+ *
6
+ * Provides centralized access to system variables, configuration management,
7
+ * and environment utilities for XyPriss applications. This class serves as
8
+ * a type-safe wrapper around system configuration with built-in helpers
9
+ * for common operations.
10
+ *
11
+ * @class XyPrissSys
12
+ * @version 1.0.0
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Initialize with default values
17
+ * const sys = new XyPrissSys({
18
+ * __version__: "1.0.0",
19
+ * __author__: "John Doe",
20
+ * __port__: 8080,
21
+ * __env__: "production"
22
+ * });
23
+ *
24
+ * // Check environment
25
+ * if (__sys__$isProduction()) {
26
+ * console.log('Running in production mode');
27
+ * }
28
+ *
29
+ * // Access variables
30
+ * const port = __sys__$get('__port__', 3000);
31
+ * ```
32
+ */
33
+ class XyPrissSys {
34
+ /**
35
+ * Creates a new XyPrissSys instance with optional initial data.
36
+ * All port-related properties are automatically synchronized.
37
+ *
38
+ * @constructor
39
+ * @param {Record<string, any>} [data={}] - Initial system variable data
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Create with defaults
44
+ * const sys = new XyPrissSys();
45
+ *
46
+ * // Create with custom data
47
+ * const sys = new XyPrissSys({
48
+ * __version__: "2.0.0",
49
+ * __author__: "Development Team",
50
+ * __port__: 8080,
51
+ * __env__: "production",
52
+ * customVar: "custom value"
53
+ * });
54
+ * ```
55
+ */
56
+ constructor(data = {}) {
57
+ /**
58
+ * Application version string following semantic versioning.
59
+ *
60
+ * @type {string}
61
+ * @default "0.0.0"
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * __sys____version__ = "1.2.3";
66
+ * console.log(`App version: ${__sys____version__}`);
67
+ * ```
68
+ */
69
+ this.__version__ = "0.0.0";
70
+ /**
71
+ * Application author or maintainer name.
72
+ *
73
+ * @type {string}
74
+ * @default "unknown"
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * __sys____author__ = "Jane Smith";
79
+ * ```
80
+ */
81
+ this.__author__ = "unknown";
82
+ /**
83
+ * Collection of application URLs for various environments or services.
84
+ * Useful for storing API endpoints, frontend URLs, or external service links.
85
+ *
86
+ * @type {Record<string, string>}
87
+ * @default {}
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * __sys____app_urls__ = {
92
+ * api: "https://api.example.com",
93
+ * frontend: "https://app.example.com",
94
+ * docs: "https://docs.example.com"
95
+ * };
96
+ *
97
+ * const apiUrl = __sys____app_urls__.api;
98
+ * ```
99
+ */
100
+ this.__app_urls__ = {};
101
+ /**
102
+ * Application name identifier.
103
+ *
104
+ * @type {string}
105
+ * @default "xypriss-app"
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * __sys____name__ = "my-awesome-app";
110
+ * ```
111
+ */
112
+ this.__name__ = "xypriss-app";
113
+ /**
114
+ * Application alias or short name.
115
+ * Used for abbreviated references or CLI commands.
116
+ *
117
+ * @type {string}
118
+ * @default "app"
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * __sys____alias__ = "myapp";
123
+ * ```
124
+ */
125
+ this.__alias__ = "app";
126
+ /**
127
+ * Server port number (lowercase variant).
128
+ * Synchronized automatically with __PORT__.
129
+ *
130
+ * @type {number}
131
+ * @default 3000
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * __sys____port__ = 8080;
136
+ * console.log(__sys____PORT__); // Also 8080 (auto-synced)
137
+ * ```
138
+ */
139
+ this.__port__ = 3000;
140
+ /**
141
+ * Server port number (uppercase variant).
142
+ * Synchronized automatically with __port__.
143
+ *
144
+ * @type {number}
145
+ * @default 3000
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * __sys____PORT__ = 5000;
150
+ * console.log(__sys____port__); // Also 5000 (auto-synced)
151
+ * ```
152
+ */
153
+ this.__PORT__ = 3000;
154
+ /**
155
+ * Current environment mode.
156
+ * Typically "development", "production", "staging", or "test".
157
+ *
158
+ * @type {string}
159
+ * @default "development"
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * __sys____env__ = "production";
164
+ * if (__sys__$isProduction()) {
165
+ * // Production-specific logic
166
+ * }
167
+ * ```
168
+ */
169
+ this.__env__ = "development";
170
+ /**
171
+ * Environment variables manager providing access to process.env.
172
+ * Offers a clean API for getting, setting, and managing environment variables.
173
+ *
174
+ * @type {Object}
175
+ * @property {Function} set - Set an environment variable
176
+ * @property {Function} get - Get an environment variable with optional default
177
+ * @property {Function} has - Check if an environment variable exists
178
+ * @property {Function} delete - Remove an environment variable
179
+ * @property {Function} all - Get all environment variables
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * // Set environment variable
184
+ * __sys____ENV__.set('API_KEY', 'secret123');
185
+ *
186
+ * // Get with default
187
+ * const apiKey = __sys____ENV__.get('API_KEY', 'default-key');
188
+ *
189
+ * // Check existence
190
+ * if (__sys____ENV__.has('DATABASE_URL')) {
191
+ * const dbUrl = __sys____ENV__.get('DATABASE_URL');
192
+ * }
193
+ *
194
+ * // Delete variable
195
+ * __sys____ENV__.delete('TEMP_VAR');
196
+ *
197
+ * // Get all variables
198
+ * const allEnv = __sys____ENV__.all();
199
+ * ```
200
+ */
201
+ this.__ENV__ = {
202
+ /**
203
+ * Set an environment variable.
204
+ *
205
+ * @param {string} key - The environment variable name
206
+ * @param {string} value - The value to set
207
+ * @returns {void}
208
+ */
209
+ set: (key, value) => {
210
+ process.env[key] = value;
211
+ },
212
+ /**
213
+ * Get an environment variable with an optional default value.
214
+ *
215
+ * @param {string} key - The environment variable name
216
+ * @param {string} [defaultValue] - Default value if variable is not set
217
+ * @returns {string | undefined} The environment variable value or default
218
+ */
219
+ get: (key, defaultValue) => {
220
+ return process.env[key] || defaultValue;
221
+ },
222
+ /**
223
+ * Check if an environment variable exists.
224
+ *
225
+ * @param {string} key - The environment variable name
226
+ * @returns {boolean} True if the variable exists
227
+ */
228
+ has: (key) => {
229
+ return process.env[key] !== undefined;
230
+ },
231
+ /**
232
+ * Delete an environment variable.
233
+ *
234
+ * @param {string} key - The environment variable name
235
+ * @returns {void}
236
+ */
237
+ delete: (key) => {
238
+ delete process.env[key];
239
+ },
240
+ /**
241
+ * Get all environment variables.
242
+ *
243
+ * @returns {NodeJS.ProcessEnv} All environment variables
244
+ */
245
+ all: () => {
246
+ return process.env;
247
+ },
248
+ };
249
+ this.$update(data);
250
+ }
251
+ /**
252
+ * Update system variables with new data.
253
+ * Automatically synchronizes __port__ and __PORT__ to maintain consistency.
254
+ * Supports backward compatibility for legacy single-underscore variants.
255
+ *
256
+ * @param {Record<string, any>} data - Partial data to merge into system variables
257
+ * @returns {void}
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * __sys__$update({
262
+ * __version__: "1.5.0",
263
+ * __port__: 9000,
264
+ * newFeature: true
265
+ * });
266
+ *
267
+ * // Port is automatically synced
268
+ * console.log(__sys____port__); // 9000
269
+ * console.log(__sys____PORT__); // 9000
270
+ * ```
271
+ */
272
+ $update(data) {
273
+ Object.assign(this, data);
274
+ // Synchronize port variants
275
+ if (data.__port__ !== undefined)
276
+ this.__PORT__ = data.__port__;
277
+ if (data.__PORT__ !== undefined)
278
+ this.__port__ = data.__PORT__;
279
+ // Backward compatibility for single underscore
280
+ if (data.__port !== undefined) {
281
+ this.__port__ = data.__port;
282
+ this.__PORT__ = data.__port;
283
+ }
284
+ if (data.__PORT !== undefined) {
285
+ this.__port__ = data.__PORT;
286
+ this.__PORT__ = data.__PORT;
287
+ }
288
+ if (data.__env !== undefined)
289
+ this.__env__ = data.__env;
290
+ }
291
+ /**
292
+ * Add or update a single system variable.
293
+ * Provides a cleaner API for adding individual properties.
294
+ *
295
+ * @param {string} key - Variable name
296
+ * @param {any} value - Variable value (any type)
297
+ * @returns {void}
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * __sys__$add('databaseUrl', 'postgresql://localhost:5432/mydb');
302
+ * __sys__$add('maxConnections', 100);
303
+ * __sys__$add('features', { darkMode: true, beta: false });
304
+ *
305
+ * console.log(__sys__databaseUrl); // 'postgresql://localhost:5432/mydb'
306
+ * console.log(__sys__maxConnections); // 100
307
+ * ```
308
+ */
309
+ $add(key, value) {
310
+ this[key] = value;
311
+ }
312
+ /**
313
+ * Remove a system variable.
314
+ *
315
+ * @param {string} key - Variable name to remove
316
+ * @returns {boolean} True if the variable existed and was removed
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * __sys__$add('tempVar', 'temporary');
321
+ * console.log(__sys__$has('tempVar')); // true
322
+ *
323
+ * __sys__$remove('tempVar');
324
+ * console.log(__sys__$has('tempVar')); // false
325
+ * ```
326
+ */
327
+ $remove(key) {
328
+ if (this.$has(key)) {
329
+ delete this[key];
330
+ return true;
331
+ }
332
+ return false;
333
+ }
334
+ /**
335
+ * Export all system variables as a plain JavaScript object.
336
+ * Excludes internal methods (starting with $) and the __ENV__ manager.
337
+ * Useful for serialization, logging, or persistence.
338
+ *
339
+ * @returns {Record<string, any>} Plain object containing all system variables
340
+ *
341
+ * @example
342
+ * ```typescript
343
+ * const config = __sys__$toJSON();
344
+ * console.log(JSON.stringify(config, null, 2));
345
+ *
346
+ * // Save to file
347
+ * fs.writeFileSync('config.json', JSON.stringify(config, null, 2));
348
+ *
349
+ * // Send in API response
350
+ * res.json({ system: config });
351
+ * ```
352
+ */
353
+ $toJSON() {
354
+ const json = {};
355
+ for (const key in this) {
356
+ if (!key.startsWith("$") &&
357
+ typeof this[key] !== "function" &&
358
+ key !== "__ENV__") {
359
+ json[key] = this[key];
360
+ }
361
+ }
362
+ return json;
363
+ }
364
+ /**
365
+ * Check if the current environment is production.
366
+ * Compares __env__ against "production" (case-sensitive).
367
+ *
368
+ * @returns {boolean} True if environment is production
369
+ *
370
+ * @example
371
+ * ```typescript
372
+ * if (__sys__$isProduction()) {
373
+ * console.log('Running in production mode');
374
+ * // Enable production optimizations
375
+ * enableCaching();
376
+ * disableDebugMode();
377
+ * }
378
+ * ```
379
+ */
380
+ $isProduction() {
381
+ return this.__env__ === "production";
382
+ }
383
+ /**
384
+ * Check if the current environment is development.
385
+ * Compares __env__ against "development" (case-sensitive).
386
+ *
387
+ * @returns {boolean} True if environment is development
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * if (__sys__$isDevelopment()) {
392
+ * console.log('Running in development mode');
393
+ * // Enable development features
394
+ * enableHotReload();
395
+ * showDebugInfo();
396
+ * }
397
+ * ```
398
+ */
399
+ $isDevelopment() {
400
+ return this.__env__ === "development";
401
+ }
402
+ /**
403
+ * Check if the current environment is staging.
404
+ * Compares __env__ against "staging" (case-sensitive).
405
+ *
406
+ * @returns {boolean} True if environment is staging
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * if (__sys__$isStaging()) {
411
+ * console.log('Running in staging mode');
412
+ * // Use staging configurations
413
+ * }
414
+ * ```
415
+ */
416
+ $isStaging() {
417
+ return this.__env__ === "staging";
418
+ }
419
+ /**
420
+ * Check if the current environment is test.
421
+ * Compares __env__ against "test" (case-sensitive).
422
+ *
423
+ * @returns {boolean} True if environment is test
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * if (__sys__$isTest()) {
428
+ * console.log('Running in test mode');
429
+ * // Use test database
430
+ * useTestDatabase();
431
+ * }
432
+ * ```
433
+ */
434
+ $isTest() {
435
+ return this.__env__ === "test";
436
+ }
437
+ /**
438
+ * Check if environment matches a custom environment name.
439
+ * Performs case-sensitive comparison.
440
+ *
441
+ * @param {string} envName - Environment name to check against
442
+ * @returns {boolean} True if current environment matches the provided name
443
+ *
444
+ * @example
445
+ * ```typescript
446
+ * if (__sys__$isEnvironment('qa')) {
447
+ * console.log('Running in QA environment');
448
+ * }
449
+ *
450
+ * if (__sys__$isEnvironment('local')) {
451
+ * // Local development specific code
452
+ * }
453
+ * ```
454
+ */
455
+ $isEnvironment(envName) {
456
+ return this.__env__ === envName;
457
+ }
458
+ /**
459
+ * Get a system variable with an optional default value.
460
+ * Type-safe retrieval with generic type parameter support.
461
+ *
462
+ * @template T - Expected type of the return value
463
+ * @param {string} key - Variable name to retrieve
464
+ * @param {T} [defaultValue] - Default value if variable doesn't exist
465
+ * @returns {T} The variable value or default value
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * // Get with type inference
470
+ * const port = __sys__$get<number>('__port__', 3000);
471
+ * const name = __sys__$get<string>('__name__', 'default-app');
472
+ *
473
+ * // Get complex types
474
+ * interface AppConfig {
475
+ * theme: string;
476
+ * features: string[];
477
+ * }
478
+ * const config = __sys__$get<AppConfig>('config', {
479
+ * theme: 'light',
480
+ * features: []
481
+ * });
482
+ *
483
+ * // Works with undefined variables
484
+ * const missing = __sys__$get('nonexistent', 'fallback'); // 'fallback'
485
+ * ```
486
+ */
487
+ $get(key, defaultValue) {
488
+ return (this[key] !== undefined ? this[key] : defaultValue);
489
+ }
490
+ /**
491
+ * Check if a system variable exists.
492
+ * Returns true even if the value is falsy (null, false, 0, empty string).
493
+ *
494
+ * @param {string} key - Variable name to check
495
+ * @returns {boolean} True if variable exists (even if falsy)
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * __sys__$add('enabled', false);
500
+ * __sys__$add('count', 0);
501
+ * __sys__$add('name', '');
502
+ *
503
+ * console.log(__sys__$has('enabled')); // true (even though value is false)
504
+ * console.log(__sys__$has('count')); // true (even though value is 0)
505
+ * console.log(__sys__$has('name')); // true (even though value is '')
506
+ * console.log(__sys__$has('missing')); // false
507
+ *
508
+ * // Conditional logic
509
+ * if (__sys__$has('apiKey')) {
510
+ * const apiKey = __sys__$get('apiKey');
511
+ * initializeAPI(apiKey);
512
+ * }
513
+ * ```
514
+ */
515
+ $has(key) {
516
+ return this[key] !== undefined;
517
+ }
518
+ /**
519
+ * Get all system variable keys.
520
+ * Excludes internal methods and the __ENV__ manager.
521
+ *
522
+ * @returns {string[]} Array of all variable names
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * const keys = __sys__$keys();
527
+ * console.log(keys); // ['__version__', '__author__', '__port__', ...]
528
+ *
529
+ * // Iterate over all variables
530
+ * keys.forEach(key => {
531
+ * console.log(`${key}: ${__sys__$get(key)}`);
532
+ * });
533
+ * ```
534
+ */
535
+ $keys() {
536
+ return Object.keys(this).filter((key) => !key.startsWith("$") &&
537
+ typeof this[key] !== "function" &&
538
+ key !== "__ENV__");
539
+ }
540
+ /**
541
+ * Reset all system variables to default values.
542
+ * Preserves the __ENV__ manager instance.
543
+ *
544
+ * @returns {void}
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * __sys__$add('customVar', 'custom');
549
+ * __sys____version__ = "2.0.0";
550
+ *
551
+ * __sys__$reset();
552
+ *
553
+ * console.log(__sys____version__); // "0.0.0" (default)
554
+ * console.log(__sys__$has('customVar')); // false
555
+ * ```
556
+ */
557
+ $reset() {
558
+ // Store __ENV__ reference
559
+ const envManager = this.__ENV__;
560
+ // Clear all properties
561
+ Object.keys(this).forEach((key) => {
562
+ if (key !== "__ENV__" && !key.startsWith("$")) {
563
+ delete this[key];
564
+ }
565
+ });
566
+ // Restore defaults
567
+ this.__version__ = "0.0.0";
568
+ this.__author__ = "unknown";
569
+ this.__app_urls__ = {};
570
+ this.__name__ = "xypriss-app";
571
+ this.__alias__ = "app";
572
+ this.__port__ = 3000;
573
+ this.__PORT__ = 3000;
574
+ this.__env__ = "development";
575
+ this.__ENV__ = envManager;
576
+ }
577
+ /**
578
+ * Clone the current system configuration.
579
+ * Creates a new instance with the same variable values.
580
+ *
581
+ * @returns {XyPrissSys} New instance with cloned values
582
+ *
583
+ * @example
584
+ * ```typescript
585
+ * const sys1 = new XyPrissSys({ __version__: "1.0.0" });
586
+ * const sys2 = sys1.$clone();
587
+ *
588
+ * sys2.__version__ = "2.0.0";
589
+ *
590
+ * console.log(sys1.__version__); // "1.0.0" (unchanged)
591
+ * console.log(sys2.__version__); // "2.0.0"
592
+ * ```
593
+ */
594
+ $clone() {
595
+ return new XyPrissSys(this.$toJSON());
596
+ }
597
+ }
598
+
599
+ exports.XyPrissSys = XyPrissSys;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AAC,SAAS,GAAG,KAAK,CAAC;AACvB,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;AACrB,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;AACrB,QAAA,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC;AAC7B,QAAA,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;KAC7B;AAED;;;;;;;;;;;;;;;;AAgBG;IACI,MAAM,GAAA;QACT,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;KACzC;AACJ;;;;"}
@@ -1,5 +1,6 @@
1
1
  export { FileUploadAPI as FLA, FileUploadAPI, Upload } from './file-upload.js';
2
2
  import { XyPrissRouter } from './server/routing/Router.js';
3
+ import { XyPrissSys } from './sys.js';
3
4
  export { createCacheMiddleware, createServer, createServerInstance } from './server/ServerFactory.js';
4
5
  export { Route } from './server/components/fastapi/smart-routes.js';
5
6
  export { createOptimalCache } from './cache/CacheFactory.js';
@@ -58,6 +59,17 @@ export { NetworkPluginUtils } from './plugins/modules/network/utils/NetworkPlugi
58
59
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
59
60
  * SOFTWARE.
60
61
  ***************************************************************************** */
62
+ // Initialize __sys__ global if it doesn't exist
63
+ if (typeof globalThis !== "undefined") {
64
+ const defaultPort = parseInt(process.env["PORT"] || "3000");
65
+ globalThis.__sys__ =
66
+ globalThis.__sys__ ||
67
+ new XyPrissSys({
68
+ __port__: defaultPort,
69
+ __PORT__: defaultPort,
70
+ __env__: process.env["NODE_ENV"] || "development",
71
+ });
72
+ }
61
73
  /**
62
74
  * Default router instance for quick start
63
75
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBiF;AA4CjF;;AAEG;SACa,MAAM,GAAA;IAClB,OAAO,IAAI,aAAa,CAAC;AACrB,QAAA,aAAa,EAAE,KAAK;AACpB,QAAA,WAAW,EAAE,KAAK;AAClB,QAAA,MAAM,EAAE,KAAK;AAChB,KAAA,CAAC,CAAC;AACP;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBiF;AAOjF;AACA,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;AACnC,IAAA,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,CAAC;AAC3D,IAAA,UAAkB,CAAC,OAAO;AACtB,QAAA,UAAkB,CAAC,OAAO;AAC3B,YAAA,IAAI,UAAU,CAAC;AACX,gBAAA,QAAQ,EAAE,WAAW;AACrB,gBAAA,QAAQ,EAAE,WAAW;gBACrB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,aAAa;AACpD,aAAA,CAAC,CAAC;AACX,CAAC;AAyCD;;AAEG;SACa,MAAM,GAAA;IAClB,OAAO,IAAI,aAAa,CAAC;AACrB,QAAA,aAAa,EAAE,KAAK;AACpB,QAAA,WAAW,EAAE,KAAK;AAClB,QAAA,MAAM,EAAE,KAAK;AAChB,KAAA,CAAC,CAAC;AACP;;;;"}
@@ -41,6 +41,15 @@ export { expressStringify, fastStringify, safeStringify } from '../../mods/secur
41
41
  function createServer(options = {}) {
42
42
  if (options.env) {
43
43
  process.env["NODE_ENV"] = options.env;
44
+ if (typeof globalThis !== "undefined" && globalThis.__sys__) {
45
+ globalThis.__sys__.$update({ __env__: options.env });
46
+ }
47
+ }
48
+ // Update __sys__ with port if provided
49
+ if (options.server?.port &&
50
+ typeof globalThis !== "undefined" &&
51
+ globalThis.__sys__) {
52
+ globalThis.__sys__.$update({ __port__: options.server.port });
44
53
  }
45
54
  // Merge user options with default configs (Configs already has defaults)
46
55
  // This makes Configs the SINGLE SOURCE OF TRUTH