@navios/commander 0.7.1 → 0.8.0

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/lib/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Container, Factory, Injectable, InjectableScope, InjectableType, InjectionToken, inject } from "@navios/di";
1
+ import { Container, Factory, Injectable, InjectableScope, InjectableType, InjectionToken, getInjectableToken, inject } from "@navios/di";
2
2
  import { env } from "node:process";
3
3
  import z, { z as z$1 } from "zod/v4";
4
4
  import { inspect } from "util";
@@ -41,7 +41,7 @@ var __copyProps = (to, from, except, desc) => {
41
41
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
42
42
 
43
43
  //#endregion
44
- //#region ../core/lib/use-guards.decorator-kZ3lNK8v.mjs
44
+ //#region ../core/lib/use-guards.decorator-CUww54Nt.mjs
45
45
  const EndpointMetadataKey = Symbol("EndpointMetadataKey");
46
46
  function getAllEndpointMetadata(context) {
47
47
  if (context.metadata) {
@@ -134,13 +134,13 @@ function hasModuleMetadata(target) {
134
134
  }
135
135
  /**
136
136
  * Decorator that marks a class as a Navios controller.
137
- *
137
+ *
138
138
  * Controllers handle HTTP requests and define endpoints.
139
139
  * They are request-scoped by default, meaning a new instance is created for each request.
140
- *
140
+ *
141
141
  * @param options - Controller configuration options
142
142
  * @returns A class decorator
143
- *
143
+ *
144
144
  * @example
145
145
  * ```typescript
146
146
  * @Controller({ guards: [AuthGuard] })
@@ -151,7 +151,7 @@ function hasModuleMetadata(target) {
151
151
  * }
152
152
  * }
153
153
  * ```
154
- */ function Controller({ guards } = {}) {
154
+ */ function Controller({ guards, registry } = {}) {
155
155
  return function(target, context) {
156
156
  if (context.kind !== "class") throw new Error("[Navios] @Controller decorator can only be used on classes.");
157
157
  const token = InjectionToken.create(target);
@@ -161,7 +161,7 @@ function hasModuleMetadata(target) {
161
161
  }
162
162
  return Injectable({
163
163
  token,
164
- scope: InjectableScope.Request
164
+ registry
165
165
  })(target, context);
166
166
  };
167
167
  }
@@ -170,40 +170,12 @@ const ExecutionContextInjectionToken = "ExecutionContextInjectionToken";
170
170
  const ExecutionContext = InjectionToken.create(ExecutionContextInjectionToken);
171
171
  const HttpAdapterToken = InjectionToken.create("HttpAdapterToken");
172
172
  const MultipartAdapterToken = InjectionToken.create("MultipartAdapterToken");
173
+ const NaviosOptionsToken = InjectionToken.create("NaviosOptionsToken");
173
174
  const Reply = InjectionToken.create("ReplyToken");
174
175
  const Request = InjectionToken.create("RequestToken");
175
176
  const StreamAdapterToken = InjectionToken.create("StreamAdapterToken");
176
177
  const XmlStreamAdapterToken = InjectionToken.create("XmlStreamAdapterToken");
177
- /**
178
- * Decorator that marks a method as an HTTP endpoint.
179
- *
180
- * The endpoint must be defined using @navios/builder's `declareEndpoint` method.
181
- * This ensures type safety and consistency between client and server.
182
- *
183
- * @param endpoint - The endpoint declaration from @navios/builder
184
- * @returns A method decorator
185
- *
186
- * @example
187
- * ```typescript
188
- * import { builder } from '@navios/builder'
189
- *
190
- * const api = builder()
191
- * const getUserEndpoint = api.declareEndpoint({
192
- * method: 'get',
193
- * url: '/users/$userId',
194
- * responseSchema: z.object({ id: z.string(), name: z.string() }),
195
- * })
196
- *
197
- * @Controller()
198
- * export class UserController {
199
- * @Endpoint(getUserEndpoint)
200
- * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
201
- * const { userId } = request.urlParams
202
- * return { id: userId, name: 'John' }
203
- * }
204
- * }
205
- * ```
206
- */ function Endpoint(endpoint) {
178
+ function Endpoint(endpoint) {
207
179
  return (target, context) => {
208
180
  if (context.kind !== "method") throw new Error("[Navios] Endpoint decorator can only be used on methods.");
209
181
  const config = endpoint.config;
@@ -308,37 +280,8 @@ const XmlStreamAdapterToken = InjectionToken.create("XmlStreamAdapterToken");
308
280
  })(target, context);
309
281
  };
310
282
  }
311
- /**
312
- * Decorator that marks a method as a multipart/form-data endpoint.
313
- *
314
- * Use this decorator for endpoints that handle file uploads or form data.
315
- * The endpoint must be defined using @navios/builder's `declareMultipart` method.
316
- *
317
- * @param endpoint - The multipart endpoint declaration from @navios/builder
318
- * @returns A method decorator
319
- *
320
- * @example
321
- * ```typescript
322
- * const uploadFileEndpoint = api.declareMultipart({
323
- * method: 'post',
324
- * url: '/upload',
325
- * requestSchema: z.object({ file: z.instanceof(File) }),
326
- * responseSchema: z.object({ url: z.string() }),
327
- * })
328
- *
329
- * @Controller()
330
- * export class FileController {
331
- * @Multipart(uploadFileEndpoint)
332
- * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>) {
333
- * const { file } = request.data
334
- * // Handle file upload
335
- * return { url: 'https://example.com/file.jpg' }
336
- * }
337
- * }
338
- * ```
339
- */ function Multipart(endpoint) {
283
+ function Multipart(endpoint) {
340
284
  return (target, context) => {
341
- if (typeof target !== "function") throw new Error("[Navios] Endpoint decorator can only be used on functions.");
342
285
  if (context.kind !== "method") throw new Error("[Navios] Endpoint decorator can only be used on methods.");
343
286
  const config = endpoint.config;
344
287
  if (context.metadata) {
@@ -353,34 +296,8 @@ const XmlStreamAdapterToken = InjectionToken.create("XmlStreamAdapterToken");
353
296
  return target;
354
297
  };
355
298
  }
356
- /**
357
- * Decorator that marks a method as a streaming endpoint.
358
- *
359
- * Use this decorator for endpoints that stream data (e.g., file downloads, SSE).
360
- * The endpoint must be defined using @navios/builder's `declareStream` method.
361
- *
362
- * @param endpoint - The stream endpoint declaration from @navios/builder
363
- * @returns A method decorator
364
- *
365
- * @example
366
- * ```typescript
367
- * const downloadFileEndpoint = api.declareStream({
368
- * method: 'get',
369
- * url: '/files/$fileId',
370
- * })
371
- *
372
- * @Controller()
373
- * export class FileController {
374
- * @Stream(downloadFileEndpoint)
375
- * async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {
376
- * const { fileId } = request.urlParams
377
- * // Stream file data to reply
378
- * }
379
- * }
380
- * ```
381
- */ function Stream(endpoint) {
299
+ function Stream(endpoint) {
382
300
  return (target, context) => {
383
- if (typeof target !== "function") throw new Error("[Navios] Endpoint decorator can only be used on functions.");
384
301
  if (context.kind !== "method") throw new Error("[Navios] Endpoint decorator can only be used on methods.");
385
302
  const config = endpoint.config;
386
303
  if (context.metadata) {
@@ -463,7 +380,7 @@ const XmlStreamAdapterToken = InjectionToken.create("XmlStreamAdapterToken");
463
380
  };
464
381
 
465
382
  //#endregion
466
- //#region ../core/lib/src-DpPBxmjz.mjs
383
+ //#region ../core/lib/src-gBAChVRL.mjs
467
384
  function envInt(key, defaultValue) {
468
385
  const envKey = env[key] || process.env[key];
469
386
  return envKey ? parseInt(envKey, 10) : defaultValue;
@@ -546,6 +463,15 @@ const isConstructor = (val) => val === "constructor";
546
463
  const isNil = (val) => isUndefined(val) || val === null;
547
464
  const isEmpty = (array) => !(array && array.length > 0);
548
465
  const isSymbol = (val) => typeof val === "symbol";
466
+ let requestCounter = 0;
467
+ /**
468
+ * Generates a simple incremental request ID.
469
+ * Much faster than crypto.randomUUID() and sufficient for request tracking.
470
+ *
471
+ * @returns A unique request ID string (e.g., "req-1", "req-2", ...)
472
+ */ function generateRequestId() {
473
+ return `req-${++requestCounter}`;
474
+ }
549
475
  /**
550
476
  * AsyncLocalStorage store for the current request ID.
551
477
  *
@@ -565,22 +491,42 @@ const isSymbol = (val) => typeof val === "symbol";
565
491
  * // Get current request ID (returns undefined if not in a request context)
566
492
  * const currentId = getRequestId()
567
493
  * ```
568
- */ const requestIdStore = new AsyncLocalStorage();
494
+ */ let requestIdStore = null;
495
+ function getRequestIdStore() {
496
+ if (!requestIdStore) requestIdStore = new AsyncLocalStorage();
497
+ return requestIdStore;
498
+ }
499
+ /**
500
+ * Whether request ID propagation is enabled.
501
+ * When disabled, runWithRequestId is a pass-through for better performance.
502
+ */ let requestIdEnabled = false;
503
+ /**
504
+ * Enables or disables request ID propagation.
505
+ * Called by NaviosFactory based on the enableRequestId option.
506
+ *
507
+ * @param enabled - Whether to enable request ID propagation
508
+ */ function setRequestIdEnabled(enabled) {
509
+ requestIdEnabled = enabled;
510
+ }
569
511
  /**
570
512
  * Runs a function with a request ID in the async local storage context.
513
+ * If request ID propagation is disabled, the function is called directly
514
+ * without AsyncLocalStorage overhead.
571
515
  *
572
516
  * @param requestId - The request ID to set for this context
573
517
  * @param fn - The function to run within this context
574
518
  * @returns The return value of the function
575
519
  */ function runWithRequestId(requestId, fn) {
576
- return requestIdStore.run(requestId, fn);
520
+ if (!requestIdEnabled) return fn();
521
+ return getRequestIdStore().run(requestId, fn);
577
522
  }
578
523
  /**
579
524
  * Gets the current request ID from the async local storage context.
580
525
  *
581
526
  * @returns The current request ID, or undefined if not in a request context
582
527
  */ function getRequestId() {
583
- return requestIdStore.getStore();
528
+ if (!requestIdEnabled) return;
529
+ return getRequestIdStore().getStore();
584
530
  }
585
531
  /**
586
532
  * Injection token for the logger output service.
@@ -602,7 +548,7 @@ const isSymbol = (val) => typeof val === "symbol";
602
548
  * logger.log('Hello world') // Logs with context: [MyService]
603
549
  * ```
604
550
  */ const Logger = InjectionToken.create("Logger", loggerOptionsSchema);
605
- function applyDecs2203RFactory$13() {
551
+ function applyDecs2203RFactory$14() {
606
552
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
607
553
  return function addInitializer(initializer) {
608
554
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -876,10 +822,10 @@ function applyDecs2203RFactory$13() {
876
822
  };
877
823
  };
878
824
  }
879
- function _apply_decs_2203_r$13(targetClass, memberDecs, classDecs, parentClass) {
880
- return (_apply_decs_2203_r$13 = applyDecs2203RFactory$13())(targetClass, memberDecs, classDecs, parentClass);
825
+ function _apply_decs_2203_r$14(targetClass, memberDecs, classDecs, parentClass) {
826
+ return (_apply_decs_2203_r$14 = applyDecs2203RFactory$14())(targetClass, memberDecs, classDecs, parentClass);
881
827
  }
882
- var _dec$13, _initClass$13;
828
+ var _dec$14, _initClass$14;
883
829
  const DEFAULT_DEPTH = 5;
884
830
  const DEFAULT_LOG_LEVELS = [
885
831
  "log",
@@ -898,10 +844,10 @@ const dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
898
844
  month: "2-digit"
899
845
  });
900
846
  let _ConsoleLogger;
901
- _dec$13 = Injectable({ token: LoggerOutput });
847
+ _dec$14 = Injectable({ token: LoggerOutput });
902
848
  (class {
903
849
  static {
904
- ({c: [_ConsoleLogger, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
850
+ ({c: [_ConsoleLogger, _initClass$14]} = _apply_decs_2203_r$14(this, [], [_dec$14]));
905
851
  }
906
852
  /**
907
853
  * The options of the logger.
@@ -1150,10 +1096,10 @@ _dec$13 = Injectable({ token: LoggerOutput });
1150
1096
  }
1151
1097
  }
1152
1098
  static {
1153
- _initClass$13();
1099
+ _initClass$14();
1154
1100
  }
1155
1101
  });
1156
- function applyDecs2203RFactory$12() {
1102
+ function applyDecs2203RFactory$13() {
1157
1103
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1158
1104
  return function addInitializer(initializer) {
1159
1105
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -1427,15 +1373,15 @@ function applyDecs2203RFactory$12() {
1427
1373
  };
1428
1374
  };
1429
1375
  }
1430
- function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass) {
1431
- return (_apply_decs_2203_r$12 = applyDecs2203RFactory$12())(targetClass, memberDecs, classDecs, parentClass);
1376
+ function _apply_decs_2203_r$13(targetClass, memberDecs, classDecs, parentClass) {
1377
+ return (_apply_decs_2203_r$13 = applyDecs2203RFactory$13())(targetClass, memberDecs, classDecs, parentClass);
1432
1378
  }
1433
- var _dec$12, _initClass$12;
1379
+ var _dec$13, _initClass$13;
1434
1380
  let _LoggerInstance;
1435
- _dec$12 = Injectable({ token: Logger });
1381
+ _dec$13 = Injectable({ token: Logger });
1436
1382
  (class {
1437
1383
  static {
1438
- ({c: [_LoggerInstance, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
1384
+ ({c: [_LoggerInstance, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
1439
1385
  }
1440
1386
  constructor(config = {}) {
1441
1387
  this.context = config.context;
@@ -1467,10 +1413,10 @@ _dec$12 = Injectable({ token: Logger });
1467
1413
  this.localInstance?.fatal?.(message, ...optionalParams);
1468
1414
  }
1469
1415
  static {
1470
- _initClass$12();
1416
+ _initClass$13();
1471
1417
  }
1472
1418
  });
1473
- function applyDecs2203RFactory$11() {
1419
+ function applyDecs2203RFactory$12() {
1474
1420
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1475
1421
  return function addInitializer(initializer) {
1476
1422
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -1744,10 +1690,10 @@ function applyDecs2203RFactory$11() {
1744
1690
  };
1745
1691
  };
1746
1692
  }
1747
- function _apply_decs_2203_r$11(targetClass, memberDecs, classDecs, parentClass) {
1748
- return (_apply_decs_2203_r$11 = applyDecs2203RFactory$11())(targetClass, memberDecs, classDecs, parentClass);
1693
+ function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass) {
1694
+ return (_apply_decs_2203_r$12 = applyDecs2203RFactory$12())(targetClass, memberDecs, classDecs, parentClass);
1749
1695
  }
1750
- var _dec$11, _initClass$11;
1696
+ var _dec$12, _initClass$12;
1751
1697
  /**
1752
1698
  * Schema for validating configuration service options.
1753
1699
  */ const ConfigServiceOptionsSchema = z$1.record(z$1.string(), z$1.unknown());
@@ -1755,11 +1701,11 @@ var _dec$11, _initClass$11;
1755
1701
  * Injection token for ConfigService.
1756
1702
  */ const ConfigServiceToken = InjectionToken.create(Symbol.for("ConfigService"), ConfigServiceOptionsSchema);
1757
1703
  let _ConfigService;
1758
- _dec$11 = Injectable({ token: ConfigServiceToken });
1704
+ _dec$12 = Injectable({ token: ConfigServiceToken });
1759
1705
  (class {
1760
1706
  config;
1761
1707
  static {
1762
- ({c: [_ConfigService, _initClass$11]} = _apply_decs_2203_r$11(this, [], [_dec$11]));
1708
+ ({c: [_ConfigService, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
1763
1709
  }
1764
1710
  /**
1765
1711
  * Creates a new ConfigService instance.
@@ -1841,7 +1787,7 @@ _dec$11 = Injectable({ token: ConfigServiceToken });
1841
1787
  return value;
1842
1788
  }
1843
1789
  static {
1844
- _initClass$11();
1790
+ _initClass$12();
1845
1791
  }
1846
1792
  });
1847
1793
  /**
@@ -2076,6 +2022,357 @@ _dec$11 = Injectable({ token: ConfigServiceToken });
2076
2022
  super(409, message, error);
2077
2023
  }
2078
2024
  };
2025
+ function applyDecs2203RFactory$11() {
2026
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2027
+ return function addInitializer(initializer) {
2028
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
2029
+ assertCallable(initializer, "An initializer");
2030
+ initializers.push(initializer);
2031
+ };
2032
+ }
2033
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2034
+ var kindStr;
2035
+ switch (kind) {
2036
+ case 1:
2037
+ kindStr = "accessor";
2038
+ break;
2039
+ case 2:
2040
+ kindStr = "method";
2041
+ break;
2042
+ case 3:
2043
+ kindStr = "getter";
2044
+ break;
2045
+ case 4:
2046
+ kindStr = "setter";
2047
+ break;
2048
+ default: kindStr = "field";
2049
+ }
2050
+ var ctx = {
2051
+ kind: kindStr,
2052
+ name: isPrivate ? "#" + name : name,
2053
+ static: isStatic,
2054
+ private: isPrivate,
2055
+ metadata
2056
+ };
2057
+ var decoratorFinishedRef = { v: false };
2058
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2059
+ var get, set;
2060
+ if (kind === 0) if (isPrivate) {
2061
+ get = desc.get;
2062
+ set = desc.set;
2063
+ } else {
2064
+ get = function() {
2065
+ return this[name];
2066
+ };
2067
+ set = function(v) {
2068
+ this[name] = v;
2069
+ };
2070
+ }
2071
+ else if (kind === 2) get = function() {
2072
+ return desc.value;
2073
+ };
2074
+ else {
2075
+ if (kind === 1 || kind === 3) get = function() {
2076
+ return desc.get.call(this);
2077
+ };
2078
+ if (kind === 1 || kind === 4) set = function(v) {
2079
+ desc.set.call(this, v);
2080
+ };
2081
+ }
2082
+ ctx.access = get && set ? {
2083
+ get,
2084
+ set
2085
+ } : get ? { get } : { set };
2086
+ try {
2087
+ return dec(value, ctx);
2088
+ } finally {
2089
+ decoratorFinishedRef.v = true;
2090
+ }
2091
+ }
2092
+ function assertNotFinished(decoratorFinishedRef, fnName) {
2093
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
2094
+ }
2095
+ function assertCallable(fn, hint) {
2096
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
2097
+ }
2098
+ function assertValidReturnValue(kind, value) {
2099
+ var type = typeof value;
2100
+ if (kind === 1) {
2101
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2102
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
2103
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
2104
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
2105
+ } else if (type !== "function") {
2106
+ var hint;
2107
+ if (kind === 0) hint = "field";
2108
+ else if (kind === 10) hint = "class";
2109
+ else hint = "method";
2110
+ throw new TypeError(hint + " decorators must return a function or void 0");
2111
+ }
2112
+ }
2113
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2114
+ var decs = decInfo[0];
2115
+ var desc, init, value;
2116
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
2117
+ get: decInfo[3],
2118
+ set: decInfo[4]
2119
+ };
2120
+ else if (kind === 3) desc = { get: decInfo[3] };
2121
+ else if (kind === 4) desc = { set: decInfo[3] };
2122
+ else desc = { value: decInfo[3] };
2123
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
2124
+ if (kind === 1) value = {
2125
+ get: desc.get,
2126
+ set: desc.set
2127
+ };
2128
+ else if (kind === 2) value = desc.value;
2129
+ else if (kind === 3) value = desc.get;
2130
+ else if (kind === 4) value = desc.set;
2131
+ var newValue, get, set;
2132
+ if (typeof decs === "function") {
2133
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2134
+ if (newValue !== void 0) {
2135
+ assertValidReturnValue(kind, newValue);
2136
+ if (kind === 0) init = newValue;
2137
+ else if (kind === 1) {
2138
+ init = newValue.init;
2139
+ get = newValue.get || value.get;
2140
+ set = newValue.set || value.set;
2141
+ value = {
2142
+ get,
2143
+ set
2144
+ };
2145
+ } else value = newValue;
2146
+ }
2147
+ } else for (var i = decs.length - 1; i >= 0; i--) {
2148
+ var dec = decs[i];
2149
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2150
+ if (newValue !== void 0) {
2151
+ assertValidReturnValue(kind, newValue);
2152
+ var newInit;
2153
+ if (kind === 0) newInit = newValue;
2154
+ else if (kind === 1) {
2155
+ newInit = newValue.init;
2156
+ get = newValue.get || value.get;
2157
+ set = newValue.set || value.set;
2158
+ value = {
2159
+ get,
2160
+ set
2161
+ };
2162
+ } else value = newValue;
2163
+ if (newInit !== void 0) if (init === void 0) init = newInit;
2164
+ else if (typeof init === "function") init = [init, newInit];
2165
+ else init.push(newInit);
2166
+ }
2167
+ }
2168
+ if (kind === 0 || kind === 1) {
2169
+ if (init === void 0) init = function(instance, init$1) {
2170
+ return init$1;
2171
+ };
2172
+ else if (typeof init !== "function") {
2173
+ var ownInitializers = init;
2174
+ init = function(instance, init$1) {
2175
+ var value$1 = init$1;
2176
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
2177
+ return value$1;
2178
+ };
2179
+ } else {
2180
+ var originalInitializer = init;
2181
+ init = function(instance, init$1) {
2182
+ return originalInitializer.call(instance, init$1);
2183
+ };
2184
+ }
2185
+ ret.push(init);
2186
+ }
2187
+ if (kind !== 0) {
2188
+ if (kind === 1) {
2189
+ desc.get = value.get;
2190
+ desc.set = value.set;
2191
+ } else if (kind === 2) desc.value = value;
2192
+ else if (kind === 3) desc.get = value;
2193
+ else if (kind === 4) desc.set = value;
2194
+ if (isPrivate) if (kind === 1) {
2195
+ ret.push(function(instance, args) {
2196
+ return value.get.call(instance, args);
2197
+ });
2198
+ ret.push(function(instance, args) {
2199
+ return value.set.call(instance, args);
2200
+ });
2201
+ } else if (kind === 2) ret.push(value);
2202
+ else ret.push(function(instance, args) {
2203
+ return value.call(instance, args);
2204
+ });
2205
+ else Object.defineProperty(base, name, desc);
2206
+ }
2207
+ }
2208
+ function applyMemberDecs(Class, decInfos, metadata) {
2209
+ var ret = [];
2210
+ var protoInitializers;
2211
+ var staticInitializers;
2212
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
2213
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
2214
+ for (var i = 0; i < decInfos.length; i++) {
2215
+ var decInfo = decInfos[i];
2216
+ if (!Array.isArray(decInfo)) continue;
2217
+ var kind = decInfo[1];
2218
+ var name = decInfo[2];
2219
+ var isPrivate = decInfo.length > 3;
2220
+ var isStatic = kind >= 5;
2221
+ var base;
2222
+ var initializers;
2223
+ if (isStatic) {
2224
+ base = Class;
2225
+ kind = kind - 5;
2226
+ staticInitializers = staticInitializers || [];
2227
+ initializers = staticInitializers;
2228
+ } else {
2229
+ base = Class.prototype;
2230
+ protoInitializers = protoInitializers || [];
2231
+ initializers = protoInitializers;
2232
+ }
2233
+ if (kind !== 0 && !isPrivate) {
2234
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
2235
+ var existingKind = existingNonFields.get(name) || 0;
2236
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
2237
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
2238
+ else existingNonFields.set(name, true);
2239
+ }
2240
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
2241
+ }
2242
+ pushInitializers(ret, protoInitializers);
2243
+ pushInitializers(ret, staticInitializers);
2244
+ return ret;
2245
+ }
2246
+ function pushInitializers(ret, initializers) {
2247
+ if (initializers) ret.push(function(instance) {
2248
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
2249
+ return instance;
2250
+ });
2251
+ }
2252
+ function applyClassDecs(targetClass, classDecs, metadata) {
2253
+ if (classDecs.length > 0) {
2254
+ var initializers = [];
2255
+ var newClass = targetClass;
2256
+ var name = targetClass.name;
2257
+ for (var i = classDecs.length - 1; i >= 0; i--) {
2258
+ var decoratorFinishedRef = { v: false };
2259
+ try {
2260
+ var nextNewClass = classDecs[i](newClass, {
2261
+ kind: "class",
2262
+ name,
2263
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
2264
+ metadata
2265
+ });
2266
+ } finally {
2267
+ decoratorFinishedRef.v = true;
2268
+ }
2269
+ if (nextNewClass !== void 0) {
2270
+ assertValidReturnValue(10, nextNewClass);
2271
+ newClass = nextNewClass;
2272
+ }
2273
+ }
2274
+ return [defineMetadata(newClass, metadata), function() {
2275
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
2276
+ }];
2277
+ }
2278
+ }
2279
+ function defineMetadata(Class, metadata) {
2280
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
2281
+ configurable: true,
2282
+ enumerable: true,
2283
+ value: metadata
2284
+ });
2285
+ }
2286
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
2287
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
2288
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
2289
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
2290
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
2291
+ return {
2292
+ e,
2293
+ get c() {
2294
+ return applyClassDecs(targetClass, classDecs, metadata);
2295
+ }
2296
+ };
2297
+ };
2298
+ }
2299
+ function _apply_decs_2203_r$11(targetClass, memberDecs, classDecs, parentClass) {
2300
+ return (_apply_decs_2203_r$11 = applyDecs2203RFactory$11())(targetClass, memberDecs, classDecs, parentClass);
2301
+ }
2302
+ var _dec$11, _initClass$11;
2303
+ let _InstanceResolverService;
2304
+ _dec$11 = Injectable();
2305
+ (class {
2306
+ static {
2307
+ ({c: [_InstanceResolverService, _initClass$11]} = _apply_decs_2203_r$11(this, [], [_dec$11]));
2308
+ }
2309
+ container = inject(Container);
2310
+ /**
2311
+ * Attempts to resolve a class instance, automatically detecting if it needs
2312
+ * request scope based on its dependencies.
2313
+ *
2314
+ * @param classType - The class to resolve
2315
+ * @returns A resolution result containing either a cached instance or resolver function
2316
+ */ async resolve(classType) {
2317
+ let cachedInstance = null;
2318
+ try {
2319
+ cachedInstance = await this.container.get(classType);
2320
+ } catch {
2321
+ const token = getInjectableToken(classType);
2322
+ this.container.getRegistry().updateScope(token, InjectableScope.Request);
2323
+ }
2324
+ return {
2325
+ cached: cachedInstance !== null,
2326
+ instance: cachedInstance,
2327
+ resolve: (scoped) => scoped.get(classType)
2328
+ };
2329
+ }
2330
+ /**
2331
+ * Attempts to resolve multiple class instances, automatically detecting if any need
2332
+ * request scope based on their dependencies.
2333
+ *
2334
+ * Returns `cached: true` only if ALL classes can be resolved as singletons.
2335
+ * If any class has request-scoped dependencies, returns `cached: false`.
2336
+ *
2337
+ * @param classTypes - The classes to resolve
2338
+ * @returns A resolution result containing either all cached instances or resolver function
2339
+ */ async resolveMany(classTypes) {
2340
+ if (classTypes.length === 0) return {
2341
+ cached: true,
2342
+ instances: [],
2343
+ classTypes: [],
2344
+ resolve: async () => []
2345
+ };
2346
+ const results = await Promise.all(classTypes.map(async (classType) => {
2347
+ try {
2348
+ return {
2349
+ success: true,
2350
+ instance: await this.container.get(classType)
2351
+ };
2352
+ } catch {
2353
+ const token = getInjectableToken(classType);
2354
+ this.container.getRegistry().updateScope(token, InjectableScope.Request);
2355
+ return {
2356
+ success: false,
2357
+ instance: null
2358
+ };
2359
+ }
2360
+ }));
2361
+ const allCached = results.every((r) => r.success);
2362
+ return {
2363
+ cached: allCached,
2364
+ instances: allCached ? results.map((r) => r.instance) : null,
2365
+ classTypes,
2366
+ resolve: (scoped) => Promise.all(classTypes.map((classType) => scoped.get(classType)))
2367
+ };
2368
+ }
2369
+ static {
2370
+ _initClass$11();
2371
+ }
2372
+ });
2373
+ /**
2374
+ * @deprecated Use InstanceResolverService instead
2375
+ */ const ControllerResolverService = _InstanceResolverService;
2079
2376
  function applyDecs2203RFactory$10() {
2080
2377
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2081
2378
  return function addInitializer(initializer) {
@@ -2361,23 +2658,40 @@ _dec$10 = Injectable();
2361
2658
  ({c: [_GuardRunnerService, _initClass$10]} = _apply_decs_2203_r$10(this, [], [_dec$10]));
2362
2659
  }
2363
2660
  logger = inject(Logger, { context: _GuardRunnerService.name });
2364
- async runGuards(allGuards, executionContext, context) {
2365
- let canActivate = true;
2366
- for (const guard of Array.from(allGuards).reverse()) {
2661
+ /**
2662
+ * Runs guards that need to be resolved from a scoped container.
2663
+ * Use this when guards have request-scoped dependencies.
2664
+ */ async runGuards(allGuards, executionContext, context) {
2665
+ const guardsArray = Array.from(allGuards).reverse();
2666
+ const guardInstances = await Promise.all(guardsArray.map(async (guard) => {
2367
2667
  const guardInstance = await context.get(guard);
2368
2668
  if (!guardInstance.canActivate) throw new Error(`[Navios] Guard ${guard.name} does not implement canActivate()`);
2369
- try {
2370
- canActivate = await guardInstance.canActivate(executionContext);
2371
- if (!canActivate) break;
2372
- } catch (error) {
2373
- if (error instanceof HttpException) {
2374
- executionContext.getReply().status(error.statusCode).send(error.response);
2375
- return false;
2376
- } else {
2377
- this.logger.error("Error running guard", error);
2378
- executionContext.getReply().status(500).send({ message: "Internal server error" });
2379
- return false;
2380
- }
2669
+ return guardInstance;
2670
+ }));
2671
+ return this.executeGuards(guardInstances, executionContext);
2672
+ }
2673
+ /**
2674
+ * Runs pre-resolved guard instances.
2675
+ * Use this when all guards are singletons and have been pre-resolved at startup.
2676
+ */ async runGuardsStatic(guardInstances, executionContext) {
2677
+ return this.executeGuards(guardInstances, executionContext);
2678
+ }
2679
+ /**
2680
+ * Shared guard execution logic.
2681
+ * Iterates through guard instances and calls canActivate on each.
2682
+ */ async executeGuards(guardInstances, executionContext) {
2683
+ let canActivate = true;
2684
+ for (const guardInstance of guardInstances) try {
2685
+ canActivate = await guardInstance.canActivate(executionContext);
2686
+ if (!canActivate) break;
2687
+ } catch (error) {
2688
+ if (error instanceof HttpException) {
2689
+ executionContext.getReply().status(error.statusCode).send(error.response);
2690
+ return false;
2691
+ } else {
2692
+ this.logger.error("Error running guard", error);
2693
+ executionContext.getReply().status(500).send({ message: "Internal server error" });
2694
+ return false;
2381
2695
  }
2382
2696
  }
2383
2697
  if (!canActivate) {
@@ -2694,6 +3008,49 @@ _dec$9 = Injectable();
2694
3008
  await this.traverseModules(appModule);
2695
3009
  this.initialized = true;
2696
3010
  }
3011
+ /**
3012
+ * Extends the module tree with additional modules or controllers.
3013
+ *
3014
+ * This method is designed to be called by plugins during registration,
3015
+ * which happens after initial module loading but before route registration.
3016
+ *
3017
+ * @param extensions - Array of module extensions to add
3018
+ * @throws Error if not initialized (loadModules must be called first)
3019
+ *
3020
+ * @example
3021
+ * ```typescript
3022
+ * // In plugin registration
3023
+ * const moduleLoader = await context.container.get(ModuleLoaderService)
3024
+ * await moduleLoader.extendModules([{
3025
+ * controllers: [OpenApiJsonController, OpenApiYamlController],
3026
+ * moduleName: 'OpenApiBunModule',
3027
+ * }])
3028
+ * ```
3029
+ */ async extendModules(extensions) {
3030
+ if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
3031
+ for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
3032
+ else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
3033
+ else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
3034
+ }
3035
+ /**
3036
+ * Registers controllers under a synthetic module.
3037
+ * Used when plugins want to add controllers without a full module class.
3038
+ */ async registerControllers(controllers, moduleName) {
3039
+ if (this.modulesMetadata.has(moduleName)) {
3040
+ const existing = this.modulesMetadata.get(moduleName);
3041
+ for (const controller of controllers) existing.controllers.add(controller);
3042
+ this.logger.debug(`Extended module ${moduleName} with ${controllers.length} controllers`);
3043
+ } else {
3044
+ const metadata = {
3045
+ controllers: new Set(controllers),
3046
+ imports: /* @__PURE__ */ new Set(),
3047
+ guards: /* @__PURE__ */ new Set(),
3048
+ customAttributes: /* @__PURE__ */ new Map()
3049
+ };
3050
+ this.modulesMetadata.set(moduleName, metadata);
3051
+ this.logger.debug(`Created module ${moduleName} with ${controllers.length} controllers`);
3052
+ }
3053
+ }
2697
3054
  async traverseModules(module, parentMetadata) {
2698
3055
  const metadata = extractModuleMetadata(module);
2699
3056
  if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
@@ -5170,7 +5527,7 @@ _dec$1$1 = Factory({ token: XmlStreamAdapterToken });
5170
5527
  _initClass$1$1();
5171
5528
  }
5172
5529
  });
5173
- function applyDecs2203RFactory$14() {
5530
+ function applyDecs2203RFactory$15() {
5174
5531
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
5175
5532
  return function addInitializer(initializer) {
5176
5533
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -5444,15 +5801,15 @@ function applyDecs2203RFactory$14() {
5444
5801
  };
5445
5802
  };
5446
5803
  }
5447
- function _apply_decs_2203_r$14(targetClass, memberDecs, classDecs, parentClass) {
5448
- return (_apply_decs_2203_r$14 = applyDecs2203RFactory$14())(targetClass, memberDecs, classDecs, parentClass);
5804
+ function _apply_decs_2203_r$15(targetClass, memberDecs, classDecs, parentClass) {
5805
+ return (_apply_decs_2203_r$15 = applyDecs2203RFactory$15())(targetClass, memberDecs, classDecs, parentClass);
5449
5806
  }
5450
- var _dec$14, _initClass$14;
5807
+ var _dec$15, _initClass$15;
5451
5808
  let _NaviosApplication;
5452
- _dec$14 = Injectable();
5809
+ _dec$15 = Injectable();
5453
5810
  (class {
5454
5811
  static {
5455
- ({c: [_NaviosApplication, _initClass$14]} = _apply_decs_2203_r$14(this, [], [_dec$14]));
5812
+ ({c: [_NaviosApplication, _initClass$15]} = _apply_decs_2203_r$15(this, [], [_dec$15]));
5456
5813
  }
5457
5814
  environment = inject(_NaviosEnvironment);
5458
5815
  moduleLoader = inject(_ModuleLoaderService);
@@ -5469,7 +5826,7 @@ _dec$14 = Injectable();
5469
5826
  /**
5470
5827
  * Sets up the application with the provided module and options.
5471
5828
  * This is called automatically by NaviosFactory.create().
5472
- *
5829
+ *
5473
5830
  * @param appModule - The root application module
5474
5831
  * @param options - Application configuration options
5475
5832
  * @internal
@@ -5480,7 +5837,7 @@ _dec$14 = Injectable();
5480
5837
  }
5481
5838
  /**
5482
5839
  * Gets the dependency injection container used by this application.
5483
- *
5840
+ *
5484
5841
  * @returns The Container instance
5485
5842
  */ getContainer() {
5486
5843
  return this.container;
@@ -5532,8 +5889,8 @@ _dec$14 = Injectable();
5532
5889
  if (!this.appModule) throw new Error("App module is not set. Call setAppModule() first.");
5533
5890
  await this.moduleLoader.loadModules(this.appModule);
5534
5891
  if (this.environment.hasHttpSetup()) await this.httpApplication?.setupHttpServer(this.options);
5535
- await this.initModules();
5536
5892
  await this.initPlugins();
5893
+ await this.initModules();
5537
5894
  if (this.environment.hasHttpSetup()) await this.httpApplication?.ready();
5538
5895
  this.isInitialized = true;
5539
5896
  this.logger.debug("Navios application initialized");
@@ -5544,11 +5901,16 @@ _dec$14 = Injectable();
5544
5901
  }
5545
5902
  async initPlugins() {
5546
5903
  if (this.plugins.length === 0) return;
5904
+ let server = null;
5905
+ try {
5906
+ server = this.httpApplication?.getServer() ?? null;
5907
+ } catch {}
5547
5908
  const context = {
5548
5909
  modules: this.moduleLoader.getAllModules(),
5549
- server: this.httpApplication?.getServer() ?? null,
5910
+ server,
5550
5911
  container: this.container,
5551
- globalPrefix: this.httpApplication?.getGlobalPrefix() ?? ""
5912
+ globalPrefix: this.httpApplication?.getGlobalPrefix() ?? "",
5913
+ moduleLoader: this.moduleLoader
5552
5914
  };
5553
5915
  for (const { plugin, options } of this.plugins) {
5554
5916
  this.logger.debug(`Initializing plugin: ${plugin.name}`);
@@ -5557,10 +5919,10 @@ _dec$14 = Injectable();
5557
5919
  }
5558
5920
  /**
5559
5921
  * Enables CORS (Cross-Origin Resource Sharing) for the application.
5560
- *
5922
+ *
5561
5923
  * @param options - CORS configuration options (adapter-specific)
5562
5924
  * @throws Error if HTTP application is not set
5563
- *
5925
+ *
5564
5926
  * @example
5565
5927
  * ```typescript
5566
5928
  * app.enableCors({
@@ -5575,10 +5937,10 @@ _dec$14 = Injectable();
5575
5937
  }
5576
5938
  /**
5577
5939
  * Enables multipart/form-data support for file uploads.
5578
- *
5940
+ *
5579
5941
  * @param options - Multipart configuration options (adapter-specific)
5580
5942
  * @throws Error if HTTP application is not set
5581
- *
5943
+ *
5582
5944
  * @example
5583
5945
  * ```typescript
5584
5946
  * app.enableMultipart({
@@ -5593,10 +5955,10 @@ _dec$14 = Injectable();
5593
5955
  }
5594
5956
  /**
5595
5957
  * Sets a global prefix for all routes.
5596
- *
5958
+ *
5597
5959
  * @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
5598
5960
  * @throws Error if HTTP application is not set
5599
- *
5961
+ *
5600
5962
  * @example
5601
5963
  * ```typescript
5602
5964
  * app.setGlobalPrefix('/api/v1')
@@ -5608,14 +5970,14 @@ _dec$14 = Injectable();
5608
5970
  }
5609
5971
  /**
5610
5972
  * Gets the underlying HTTP server instance.
5611
- *
5973
+ *
5612
5974
  * The type of the returned server depends on the adapter used:
5613
5975
  * - Fastify adapter: Returns FastifyInstance
5614
5976
  * - Bun adapter: Returns Bun.Server
5615
- *
5977
+ *
5616
5978
  * @returns The HTTP server instance
5617
5979
  * @throws Error if HTTP application is not set
5618
- *
5980
+ *
5619
5981
  * @example
5620
5982
  * ```typescript
5621
5983
  * const server = app.getServer()
@@ -5627,10 +5989,10 @@ _dec$14 = Injectable();
5627
5989
  }
5628
5990
  /**
5629
5991
  * Starts the HTTP server and begins listening for requests.
5630
- *
5992
+ *
5631
5993
  * @param options - Listen options (port, host, etc.)
5632
5994
  * @throws Error if HTTP application is not set
5633
- *
5995
+ *
5634
5996
  * @example
5635
5997
  * ```typescript
5636
5998
  * await app.listen({ port: 3000, host: '0.0.0.0' })
@@ -5641,7 +6003,7 @@ _dec$14 = Injectable();
5641
6003
  }
5642
6004
  /**
5643
6005
  * Disposes of application resources.
5644
- *
6006
+ *
5645
6007
  * Cleans up the HTTP server and module loader.
5646
6008
  * This method is called automatically by `close()`.
5647
6009
  */ async dispose() {
@@ -5650,9 +6012,9 @@ _dec$14 = Injectable();
5650
6012
  }
5651
6013
  /**
5652
6014
  * Closes the application and cleans up all resources.
5653
- *
6015
+ *
5654
6016
  * This is an alias for `dispose()`.
5655
- *
6017
+ *
5656
6018
  * @example
5657
6019
  * ```typescript
5658
6020
  * // Graceful shutdown
@@ -5665,36 +6027,36 @@ _dec$14 = Injectable();
5665
6027
  await this.dispose();
5666
6028
  }
5667
6029
  static {
5668
- _initClass$14();
6030
+ _initClass$15();
5669
6031
  }
5670
6032
  });
5671
6033
  /**
5672
6034
  * Factory class for creating and configuring Navios applications.
5673
- *
6035
+ *
5674
6036
  * This is the main entry point for bootstrapping a Navios application.
5675
6037
  * It handles dependency injection container setup, adapter registration,
5676
6038
  * and logger configuration.
5677
- *
6039
+ *
5678
6040
  * @example
5679
6041
  * ```typescript
5680
6042
  * import { NaviosFactory } from '@navios/core'
5681
6043
  * import { defineFastifyEnvironment } from '@navios/adapter-fastify'
5682
- *
6044
+ *
5683
6045
  * const app = await NaviosFactory.create(AppModule, {
5684
6046
  * adapter: defineFastifyEnvironment(),
5685
6047
  * logger: ['log', 'error', 'warn'],
5686
6048
  * })
5687
- *
6049
+ *
5688
6050
  * await app.init()
5689
6051
  * await app.listen({ port: 3000 })
5690
6052
  * ```
5691
6053
  */ var NaviosFactory = class {
5692
6054
  /**
5693
6055
  * Creates a new Navios application instance.
5694
- *
6056
+ *
5695
6057
  * This method sets up the dependency injection container, registers the HTTP adapter,
5696
6058
  * configures logging, and initializes the application with the provided module.
5697
- *
6059
+ *
5698
6060
  * @param appModule - The root application module class decorated with @Module()
5699
6061
  * @param options - Configuration options for the application
5700
6062
  * @param options.adapter - HTTP adapter environment (required for HTTP server functionality)
@@ -5704,20 +6066,20 @@ _dec$14 = Injectable();
5704
6066
  * - `false` to disable logging
5705
6067
  * @param options.container - Optional custom dependency injection container (useful for testing)
5706
6068
  * @returns A configured NaviosApplication instance ready to be initialized
5707
- *
6069
+ *
5708
6070
  * @example
5709
6071
  * ```typescript
5710
6072
  * // Basic setup with Fastify adapter
5711
6073
  * const app = await NaviosFactory.create(AppModule, {
5712
6074
  * adapter: defineFastifyEnvironment(),
5713
6075
  * })
5714
- *
6076
+ *
5715
6077
  * // With custom logger configuration
5716
6078
  * const app = await NaviosFactory.create(AppModule, {
5717
6079
  * adapter: defineFastifyEnvironment(),
5718
6080
  * logger: ['error', 'warn', 'log'],
5719
6081
  * })
5720
- *
6082
+ *
5721
6083
  * // With custom container for testing
5722
6084
  * const container = new Container()
5723
6085
  * const app = await NaviosFactory.create(AppModule, {
@@ -5727,6 +6089,8 @@ _dec$14 = Injectable();
5727
6089
  * ```
5728
6090
  */ static async create(appModule, options = { adapter: [] }) {
5729
6091
  const container = options.container ?? new Container();
6092
+ if (options.enableRequestId === true) setRequestIdEnabled(true);
6093
+ container.getServiceLocator().getManager().storeCreatedHolder(NaviosOptionsToken.toString(), options, InjectableType.Class, InjectableScope.Singleton);
5730
6094
  await this.registerLoggerConfiguration(container, options);
5731
6095
  const adapters = Array.isArray(options.adapter) ? options.adapter : [options.adapter];
5732
6096
  for (const adapter of adapters) await this.registerEnvironment(container, adapter);
@@ -5741,7 +6105,10 @@ _dec$14 = Injectable();
5741
6105
  }
5742
6106
  static async registerLoggerConfiguration(container, options) {
5743
6107
  const { logger } = options;
5744
- if (Array.isArray(logger) || isNil(logger)) (await container.get(LoggerOutput))?.setup({ logLevels: logger });
6108
+ if (Array.isArray(logger) || isNil(logger)) {
6109
+ (await container.get(LoggerOutput))?.setup({ logLevels: logger });
6110
+ return;
6111
+ }
5745
6112
  if (logger !== true && !isNil(logger)) container.getServiceLocator().getManager().storeCreatedHolder(LoggerOutput.toString(), logger, InjectableType.Class, InjectableScope.Singleton);
5746
6113
  }
5747
6114
  };
@@ -5759,6 +6126,7 @@ var lib_exports = /* @__PURE__ */ __export({
5759
6126
  ConsoleLogger: () => _ConsoleLogger,
5760
6127
  Controller: () => Controller,
5761
6128
  ControllerMetadataKey: () => ControllerMetadataKey,
6129
+ ControllerResolverService: () => ControllerResolverService,
5762
6130
  Endpoint: () => Endpoint,
5763
6131
  EndpointAdapterFactory: () => _EndpointAdapterFactory,
5764
6132
  EndpointAdapterToken: () => EndpointAdapterToken,
@@ -5773,6 +6141,7 @@ var lib_exports = /* @__PURE__ */ __export({
5773
6141
  HttpAdapterToken: () => HttpAdapterToken,
5774
6142
  HttpCode: () => HttpCode,
5775
6143
  HttpException: () => HttpException,
6144
+ InstanceResolverService: () => _InstanceResolverService,
5776
6145
  InternalServerErrorException: () => InternalServerErrorException,
5777
6146
  LOG_LEVELS: () => LOG_LEVELS,
5778
6147
  Logger: () => Logger,
@@ -5786,6 +6155,7 @@ var lib_exports = /* @__PURE__ */ __export({
5786
6155
  MultipartAdapterToken: () => MultipartAdapterToken,
5787
6156
  NaviosApplication: () => _NaviosApplication,
5788
6157
  NaviosFactory: () => NaviosFactory,
6158
+ NaviosOptionsToken: () => NaviosOptionsToken,
5789
6159
  NotFoundException: () => NotFoundException,
5790
6160
  Reply: () => Reply,
5791
6161
  ReplyFactory: () => _ReplyFactory,
@@ -5805,6 +6175,7 @@ var lib_exports = /* @__PURE__ */ __export({
5805
6175
  extractControllerMetadata: () => extractControllerMetadata,
5806
6176
  extractModuleMetadata: () => extractModuleMetadata,
5807
6177
  filterLogLevels: () => filterLogLevels,
6178
+ generateRequestId: () => generateRequestId,
5808
6179
  getAllEndpointMetadata: () => getAllEndpointMetadata,
5809
6180
  getControllerMetadata: () => getControllerMetadata,
5810
6181
  getEndpointMetadata: () => getEndpointMetadata,
@@ -5827,8 +6198,8 @@ var lib_exports = /* @__PURE__ */ __export({
5827
6198
  loggerOptionsSchema: () => loggerOptionsSchema,
5828
6199
  normalizePath: () => normalizePath,
5829
6200
  provideConfig: () => provideConfig,
5830
- requestIdStore: () => requestIdStore,
5831
6201
  runWithRequestId: () => runWithRequestId,
6202
+ setRequestIdEnabled: () => setRequestIdEnabled,
5832
6203
  stripEndSlash: () => stripEndSlash,
5833
6204
  yellow: () => yellow
5834
6205
  });
@@ -7478,6 +7849,7 @@ var src_exports = /* @__PURE__ */ __export({
7478
7849
  ConsoleLogger: () => _ConsoleLogger,
7479
7850
  Controller: () => Controller,
7480
7851
  ControllerMetadataKey: () => ControllerMetadataKey,
7852
+ ControllerResolverService: () => ControllerResolverService,
7481
7853
  Endpoint: () => Endpoint,
7482
7854
  EndpointAdapterFactory: () => _EndpointAdapterFactory,
7483
7855
  EndpointAdapterToken: () => EndpointAdapterToken,
@@ -7492,6 +7864,7 @@ var src_exports = /* @__PURE__ */ __export({
7492
7864
  HttpAdapterToken: () => HttpAdapterToken,
7493
7865
  HttpCode: () => HttpCode,
7494
7866
  HttpException: () => HttpException,
7867
+ InstanceResolverService: () => _InstanceResolverService,
7495
7868
  InternalServerErrorException: () => InternalServerErrorException,
7496
7869
  LOG_LEVELS: () => LOG_LEVELS,
7497
7870
  Logger: () => Logger,
@@ -7505,6 +7878,7 @@ var src_exports = /* @__PURE__ */ __export({
7505
7878
  MultipartAdapterToken: () => MultipartAdapterToken,
7506
7879
  NaviosApplication: () => _NaviosApplication,
7507
7880
  NaviosFactory: () => NaviosFactory,
7881
+ NaviosOptionsToken: () => NaviosOptionsToken,
7508
7882
  NotFoundException: () => NotFoundException,
7509
7883
  Reply: () => Reply,
7510
7884
  ReplyFactory: () => _ReplyFactory,
@@ -7526,6 +7900,7 @@ var src_exports = /* @__PURE__ */ __export({
7526
7900
  extractControllerMetadata: () => extractControllerMetadata,
7527
7901
  extractModuleMetadata: () => extractModuleMetadata,
7528
7902
  filterLogLevels: () => filterLogLevels,
7903
+ generateRequestId: () => generateRequestId,
7529
7904
  getAllEndpointMetadata: () => getAllEndpointMetadata,
7530
7905
  getCliModuleMetadata: () => getCliModuleMetadata,
7531
7906
  getCommandMetadata: () => getCommandMetadata,
@@ -7552,13 +7927,13 @@ var src_exports = /* @__PURE__ */ __export({
7552
7927
  loggerOptionsSchema: () => loggerOptionsSchema,
7553
7928
  normalizePath: () => normalizePath,
7554
7929
  provideConfig: () => provideConfig,
7555
- requestIdStore: () => requestIdStore,
7556
7930
  runWithRequestId: () => runWithRequestId,
7931
+ setRequestIdEnabled: () => setRequestIdEnabled,
7557
7932
  stripEndSlash: () => stripEndSlash,
7558
7933
  yellow: () => yellow
7559
7934
  });
7560
7935
  __reExport(src_exports, lib_exports);
7561
7936
 
7562
7937
  //#endregion
7563
- export { AttributeFactory, BadRequestException, CliModule, _CliModuleLoaderService as CliModuleLoaderService, CliModuleMetadataKey, _CliParserService as CliParserService, Command, CommandExecutionContext, CommandMetadataKey, _CommanderApplication as CommanderApplication, CommanderExecutionContext, CommanderFactory, ConfigProviderOptions, _ConfigService as ConfigService, ConfigServiceOptionsSchema, ConfigServiceToken, ConflictException, _ConsoleLogger as ConsoleLogger, Controller, ControllerMetadataKey, Endpoint, _EndpointAdapterFactory as EndpointAdapterFactory, EndpointAdapterToken, EndpointMetadataKey, EnvConfigProvider, ExecutionContext, ExecutionContextInjectionToken, ForbiddenException, _GuardRunnerService as GuardRunnerService, Header, _HttpAdapterFactory as HttpAdapterFactory, HttpAdapterToken, HttpCode, HttpException, InternalServerErrorException, LOG_LEVELS, Logger, _LoggerInstance as LoggerInstance, LoggerOutput, Module, _ModuleLoaderService as ModuleLoaderService, ModuleMetadataKey, Multipart, _MultipartAdapterFactory as MultipartAdapterFactory, MultipartAdapterToken, _NaviosApplication as NaviosApplication, NaviosFactory, NotFoundException, Reply, _ReplyFactory as ReplyFactory, Request, _RequestFactory as RequestFactory, Stream, _StreamAdapterFactory as StreamAdapterFactory, StreamAdapterToken, UnauthorizedException, UseGuards, _XmlStreamAdapterFactory as XmlStreamAdapterFactory, XmlStreamAdapterToken, addLeadingSlash, clc, envInt, envString, extractCliModuleMetadata, extractCommandMetadata, extractControllerMetadata, extractModuleMetadata, filterLogLevels, getAllEndpointMetadata, getCliModuleMetadata, getCommandMetadata, getControllerMetadata, getEndpointMetadata, getModuleMetadata, getRequestId, hasCliModuleMetadata, hasCommandMetadata, hasControllerMetadata, hasModuleMetadata, isConstructor, isEmpty, isFunction, isLogLevel, isLogLevelEnabled, isNil, isNumber, isObject, isPlainObject, isString, isSymbol, isUndefined, loggerOptionsSchema, normalizePath, provideConfig, requestIdStore, runWithRequestId, stripEndSlash, yellow };
7938
+ export { AttributeFactory, BadRequestException, CliModule, _CliModuleLoaderService as CliModuleLoaderService, CliModuleMetadataKey, _CliParserService as CliParserService, Command, CommandExecutionContext, CommandMetadataKey, _CommanderApplication as CommanderApplication, CommanderExecutionContext, CommanderFactory, ConfigProviderOptions, _ConfigService as ConfigService, ConfigServiceOptionsSchema, ConfigServiceToken, ConflictException, _ConsoleLogger as ConsoleLogger, Controller, ControllerMetadataKey, ControllerResolverService, Endpoint, _EndpointAdapterFactory as EndpointAdapterFactory, EndpointAdapterToken, EndpointMetadataKey, EnvConfigProvider, ExecutionContext, ExecutionContextInjectionToken, ForbiddenException, _GuardRunnerService as GuardRunnerService, Header, _HttpAdapterFactory as HttpAdapterFactory, HttpAdapterToken, HttpCode, HttpException, _InstanceResolverService as InstanceResolverService, InternalServerErrorException, LOG_LEVELS, Logger, _LoggerInstance as LoggerInstance, LoggerOutput, Module, _ModuleLoaderService as ModuleLoaderService, ModuleMetadataKey, Multipart, _MultipartAdapterFactory as MultipartAdapterFactory, MultipartAdapterToken, _NaviosApplication as NaviosApplication, NaviosFactory, NaviosOptionsToken, NotFoundException, Reply, _ReplyFactory as ReplyFactory, Request, _RequestFactory as RequestFactory, Stream, _StreamAdapterFactory as StreamAdapterFactory, StreamAdapterToken, UnauthorizedException, UseGuards, _XmlStreamAdapterFactory as XmlStreamAdapterFactory, XmlStreamAdapterToken, addLeadingSlash, clc, envInt, envString, extractCliModuleMetadata, extractCommandMetadata, extractControllerMetadata, extractModuleMetadata, filterLogLevels, generateRequestId, getAllEndpointMetadata, getCliModuleMetadata, getCommandMetadata, getControllerMetadata, getEndpointMetadata, getModuleMetadata, getRequestId, hasCliModuleMetadata, hasCommandMetadata, hasControllerMetadata, hasModuleMetadata, isConstructor, isEmpty, isFunction, isLogLevel, isLogLevelEnabled, isNil, isNumber, isObject, isPlainObject, isString, isSymbol, isUndefined, loggerOptionsSchema, normalizePath, provideConfig, runWithRequestId, setRequestIdEnabled, stripEndSlash, yellow };
7564
7939
  //# sourceMappingURL=index.mjs.map