@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.cjs CHANGED
@@ -46,7 +46,7 @@ zod_v4 = __toESM(zod_v4);
46
46
  let util = require("util");
47
47
  let node_async_hooks = require("node:async_hooks");
48
48
 
49
- //#region ../core/lib/use-guards.decorator-kZ3lNK8v.mjs
49
+ //#region ../core/lib/use-guards.decorator-CUww54Nt.mjs
50
50
  const EndpointMetadataKey = Symbol("EndpointMetadataKey");
51
51
  function getAllEndpointMetadata(context) {
52
52
  if (context.metadata) {
@@ -139,13 +139,13 @@ function hasModuleMetadata(target) {
139
139
  }
140
140
  /**
141
141
  * Decorator that marks a class as a Navios controller.
142
- *
142
+ *
143
143
  * Controllers handle HTTP requests and define endpoints.
144
144
  * They are request-scoped by default, meaning a new instance is created for each request.
145
- *
145
+ *
146
146
  * @param options - Controller configuration options
147
147
  * @returns A class decorator
148
- *
148
+ *
149
149
  * @example
150
150
  * ```typescript
151
151
  * @Controller({ guards: [AuthGuard] })
@@ -156,7 +156,7 @@ function hasModuleMetadata(target) {
156
156
  * }
157
157
  * }
158
158
  * ```
159
- */ function Controller({ guards } = {}) {
159
+ */ function Controller({ guards, registry } = {}) {
160
160
  return function(target, context) {
161
161
  if (context.kind !== "class") throw new Error("[Navios] @Controller decorator can only be used on classes.");
162
162
  const token = _navios_di.InjectionToken.create(target);
@@ -166,7 +166,7 @@ function hasModuleMetadata(target) {
166
166
  }
167
167
  return (0, _navios_di.Injectable)({
168
168
  token,
169
- scope: _navios_di.InjectableScope.Request
169
+ registry
170
170
  })(target, context);
171
171
  };
172
172
  }
@@ -175,40 +175,12 @@ const ExecutionContextInjectionToken = "ExecutionContextInjectionToken";
175
175
  const ExecutionContext = _navios_di.InjectionToken.create(ExecutionContextInjectionToken);
176
176
  const HttpAdapterToken = _navios_di.InjectionToken.create("HttpAdapterToken");
177
177
  const MultipartAdapterToken = _navios_di.InjectionToken.create("MultipartAdapterToken");
178
+ const NaviosOptionsToken = _navios_di.InjectionToken.create("NaviosOptionsToken");
178
179
  const Reply = _navios_di.InjectionToken.create("ReplyToken");
179
180
  const Request = _navios_di.InjectionToken.create("RequestToken");
180
181
  const StreamAdapterToken = _navios_di.InjectionToken.create("StreamAdapterToken");
181
182
  const XmlStreamAdapterToken = _navios_di.InjectionToken.create("XmlStreamAdapterToken");
182
- /**
183
- * Decorator that marks a method as an HTTP endpoint.
184
- *
185
- * The endpoint must be defined using @navios/builder's `declareEndpoint` method.
186
- * This ensures type safety and consistency between client and server.
187
- *
188
- * @param endpoint - The endpoint declaration from @navios/builder
189
- * @returns A method decorator
190
- *
191
- * @example
192
- * ```typescript
193
- * import { builder } from '@navios/builder'
194
- *
195
- * const api = builder()
196
- * const getUserEndpoint = api.declareEndpoint({
197
- * method: 'get',
198
- * url: '/users/$userId',
199
- * responseSchema: z.object({ id: z.string(), name: z.string() }),
200
- * })
201
- *
202
- * @Controller()
203
- * export class UserController {
204
- * @Endpoint(getUserEndpoint)
205
- * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
206
- * const { userId } = request.urlParams
207
- * return { id: userId, name: 'John' }
208
- * }
209
- * }
210
- * ```
211
- */ function Endpoint(endpoint) {
183
+ function Endpoint(endpoint) {
212
184
  return (target, context) => {
213
185
  if (context.kind !== "method") throw new Error("[Navios] Endpoint decorator can only be used on methods.");
214
186
  const config = endpoint.config;
@@ -313,37 +285,8 @@ const XmlStreamAdapterToken = _navios_di.InjectionToken.create("XmlStreamAdapter
313
285
  })(target, context);
314
286
  };
315
287
  }
316
- /**
317
- * Decorator that marks a method as a multipart/form-data endpoint.
318
- *
319
- * Use this decorator for endpoints that handle file uploads or form data.
320
- * The endpoint must be defined using @navios/builder's `declareMultipart` method.
321
- *
322
- * @param endpoint - The multipart endpoint declaration from @navios/builder
323
- * @returns A method decorator
324
- *
325
- * @example
326
- * ```typescript
327
- * const uploadFileEndpoint = api.declareMultipart({
328
- * method: 'post',
329
- * url: '/upload',
330
- * requestSchema: z.object({ file: z.instanceof(File) }),
331
- * responseSchema: z.object({ url: z.string() }),
332
- * })
333
- *
334
- * @Controller()
335
- * export class FileController {
336
- * @Multipart(uploadFileEndpoint)
337
- * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>) {
338
- * const { file } = request.data
339
- * // Handle file upload
340
- * return { url: 'https://example.com/file.jpg' }
341
- * }
342
- * }
343
- * ```
344
- */ function Multipart(endpoint) {
288
+ function Multipart(endpoint) {
345
289
  return (target, context) => {
346
- if (typeof target !== "function") throw new Error("[Navios] Endpoint decorator can only be used on functions.");
347
290
  if (context.kind !== "method") throw new Error("[Navios] Endpoint decorator can only be used on methods.");
348
291
  const config = endpoint.config;
349
292
  if (context.metadata) {
@@ -358,34 +301,8 @@ const XmlStreamAdapterToken = _navios_di.InjectionToken.create("XmlStreamAdapter
358
301
  return target;
359
302
  };
360
303
  }
361
- /**
362
- * Decorator that marks a method as a streaming endpoint.
363
- *
364
- * Use this decorator for endpoints that stream data (e.g., file downloads, SSE).
365
- * The endpoint must be defined using @navios/builder's `declareStream` method.
366
- *
367
- * @param endpoint - The stream endpoint declaration from @navios/builder
368
- * @returns A method decorator
369
- *
370
- * @example
371
- * ```typescript
372
- * const downloadFileEndpoint = api.declareStream({
373
- * method: 'get',
374
- * url: '/files/$fileId',
375
- * })
376
- *
377
- * @Controller()
378
- * export class FileController {
379
- * @Stream(downloadFileEndpoint)
380
- * async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {
381
- * const { fileId } = request.urlParams
382
- * // Stream file data to reply
383
- * }
384
- * }
385
- * ```
386
- */ function Stream(endpoint) {
304
+ function Stream(endpoint) {
387
305
  return (target, context) => {
388
- if (typeof target !== "function") throw new Error("[Navios] Endpoint decorator can only be used on functions.");
389
306
  if (context.kind !== "method") throw new Error("[Navios] Endpoint decorator can only be used on methods.");
390
307
  const config = endpoint.config;
391
308
  if (context.metadata) {
@@ -468,7 +385,7 @@ const XmlStreamAdapterToken = _navios_di.InjectionToken.create("XmlStreamAdapter
468
385
  };
469
386
 
470
387
  //#endregion
471
- //#region ../core/lib/src-DpPBxmjz.mjs
388
+ //#region ../core/lib/src-gBAChVRL.mjs
472
389
  function envInt(key, defaultValue) {
473
390
  const envKey = node_process.env[key] || process.env[key];
474
391
  return envKey ? parseInt(envKey, 10) : defaultValue;
@@ -551,6 +468,15 @@ const isConstructor = (val) => val === "constructor";
551
468
  const isNil = (val) => isUndefined(val) || val === null;
552
469
  const isEmpty = (array) => !(array && array.length > 0);
553
470
  const isSymbol = (val) => typeof val === "symbol";
471
+ let requestCounter = 0;
472
+ /**
473
+ * Generates a simple incremental request ID.
474
+ * Much faster than crypto.randomUUID() and sufficient for request tracking.
475
+ *
476
+ * @returns A unique request ID string (e.g., "req-1", "req-2", ...)
477
+ */ function generateRequestId() {
478
+ return `req-${++requestCounter}`;
479
+ }
554
480
  /**
555
481
  * AsyncLocalStorage store for the current request ID.
556
482
  *
@@ -570,22 +496,42 @@ const isSymbol = (val) => typeof val === "symbol";
570
496
  * // Get current request ID (returns undefined if not in a request context)
571
497
  * const currentId = getRequestId()
572
498
  * ```
573
- */ const requestIdStore = new node_async_hooks.AsyncLocalStorage();
499
+ */ let requestIdStore = null;
500
+ function getRequestIdStore() {
501
+ if (!requestIdStore) requestIdStore = new node_async_hooks.AsyncLocalStorage();
502
+ return requestIdStore;
503
+ }
504
+ /**
505
+ * Whether request ID propagation is enabled.
506
+ * When disabled, runWithRequestId is a pass-through for better performance.
507
+ */ let requestIdEnabled = false;
508
+ /**
509
+ * Enables or disables request ID propagation.
510
+ * Called by NaviosFactory based on the enableRequestId option.
511
+ *
512
+ * @param enabled - Whether to enable request ID propagation
513
+ */ function setRequestIdEnabled(enabled) {
514
+ requestIdEnabled = enabled;
515
+ }
574
516
  /**
575
517
  * Runs a function with a request ID in the async local storage context.
518
+ * If request ID propagation is disabled, the function is called directly
519
+ * without AsyncLocalStorage overhead.
576
520
  *
577
521
  * @param requestId - The request ID to set for this context
578
522
  * @param fn - The function to run within this context
579
523
  * @returns The return value of the function
580
524
  */ function runWithRequestId(requestId, fn) {
581
- return requestIdStore.run(requestId, fn);
525
+ if (!requestIdEnabled) return fn();
526
+ return getRequestIdStore().run(requestId, fn);
582
527
  }
583
528
  /**
584
529
  * Gets the current request ID from the async local storage context.
585
530
  *
586
531
  * @returns The current request ID, or undefined if not in a request context
587
532
  */ function getRequestId() {
588
- return requestIdStore.getStore();
533
+ if (!requestIdEnabled) return;
534
+ return getRequestIdStore().getStore();
589
535
  }
590
536
  /**
591
537
  * Injection token for the logger output service.
@@ -607,7 +553,7 @@ const isSymbol = (val) => typeof val === "symbol";
607
553
  * logger.log('Hello world') // Logs with context: [MyService]
608
554
  * ```
609
555
  */ const Logger = _navios_di.InjectionToken.create("Logger", loggerOptionsSchema);
610
- function applyDecs2203RFactory$13() {
556
+ function applyDecs2203RFactory$14() {
611
557
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
612
558
  return function addInitializer(initializer) {
613
559
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -881,10 +827,10 @@ function applyDecs2203RFactory$13() {
881
827
  };
882
828
  };
883
829
  }
884
- function _apply_decs_2203_r$13(targetClass, memberDecs, classDecs, parentClass) {
885
- return (_apply_decs_2203_r$13 = applyDecs2203RFactory$13())(targetClass, memberDecs, classDecs, parentClass);
830
+ function _apply_decs_2203_r$14(targetClass, memberDecs, classDecs, parentClass) {
831
+ return (_apply_decs_2203_r$14 = applyDecs2203RFactory$14())(targetClass, memberDecs, classDecs, parentClass);
886
832
  }
887
- var _dec$13, _initClass$13;
833
+ var _dec$14, _initClass$14;
888
834
  const DEFAULT_DEPTH = 5;
889
835
  const DEFAULT_LOG_LEVELS = [
890
836
  "log",
@@ -903,10 +849,10 @@ const dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
903
849
  month: "2-digit"
904
850
  });
905
851
  let _ConsoleLogger;
906
- _dec$13 = (0, _navios_di.Injectable)({ token: LoggerOutput });
852
+ _dec$14 = (0, _navios_di.Injectable)({ token: LoggerOutput });
907
853
  (class {
908
854
  static {
909
- ({c: [_ConsoleLogger, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
855
+ ({c: [_ConsoleLogger, _initClass$14]} = _apply_decs_2203_r$14(this, [], [_dec$14]));
910
856
  }
911
857
  /**
912
858
  * The options of the logger.
@@ -1155,10 +1101,10 @@ _dec$13 = (0, _navios_di.Injectable)({ token: LoggerOutput });
1155
1101
  }
1156
1102
  }
1157
1103
  static {
1158
- _initClass$13();
1104
+ _initClass$14();
1159
1105
  }
1160
1106
  });
1161
- function applyDecs2203RFactory$12() {
1107
+ function applyDecs2203RFactory$13() {
1162
1108
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1163
1109
  return function addInitializer(initializer) {
1164
1110
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -1432,15 +1378,15 @@ function applyDecs2203RFactory$12() {
1432
1378
  };
1433
1379
  };
1434
1380
  }
1435
- function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass) {
1436
- return (_apply_decs_2203_r$12 = applyDecs2203RFactory$12())(targetClass, memberDecs, classDecs, parentClass);
1381
+ function _apply_decs_2203_r$13(targetClass, memberDecs, classDecs, parentClass) {
1382
+ return (_apply_decs_2203_r$13 = applyDecs2203RFactory$13())(targetClass, memberDecs, classDecs, parentClass);
1437
1383
  }
1438
- var _dec$12, _initClass$12;
1384
+ var _dec$13, _initClass$13;
1439
1385
  let _LoggerInstance;
1440
- _dec$12 = (0, _navios_di.Injectable)({ token: Logger });
1386
+ _dec$13 = (0, _navios_di.Injectable)({ token: Logger });
1441
1387
  (class {
1442
1388
  static {
1443
- ({c: [_LoggerInstance, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
1389
+ ({c: [_LoggerInstance, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
1444
1390
  }
1445
1391
  constructor(config = {}) {
1446
1392
  this.context = config.context;
@@ -1472,10 +1418,10 @@ _dec$12 = (0, _navios_di.Injectable)({ token: Logger });
1472
1418
  this.localInstance?.fatal?.(message, ...optionalParams);
1473
1419
  }
1474
1420
  static {
1475
- _initClass$12();
1421
+ _initClass$13();
1476
1422
  }
1477
1423
  });
1478
- function applyDecs2203RFactory$11() {
1424
+ function applyDecs2203RFactory$12() {
1479
1425
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1480
1426
  return function addInitializer(initializer) {
1481
1427
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -1749,10 +1695,10 @@ function applyDecs2203RFactory$11() {
1749
1695
  };
1750
1696
  };
1751
1697
  }
1752
- function _apply_decs_2203_r$11(targetClass, memberDecs, classDecs, parentClass) {
1753
- return (_apply_decs_2203_r$11 = applyDecs2203RFactory$11())(targetClass, memberDecs, classDecs, parentClass);
1698
+ function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass) {
1699
+ return (_apply_decs_2203_r$12 = applyDecs2203RFactory$12())(targetClass, memberDecs, classDecs, parentClass);
1754
1700
  }
1755
- var _dec$11, _initClass$11;
1701
+ var _dec$12, _initClass$12;
1756
1702
  /**
1757
1703
  * Schema for validating configuration service options.
1758
1704
  */ const ConfigServiceOptionsSchema = zod_v4.z.record(zod_v4.z.string(), zod_v4.z.unknown());
@@ -1760,11 +1706,11 @@ var _dec$11, _initClass$11;
1760
1706
  * Injection token for ConfigService.
1761
1707
  */ const ConfigServiceToken = _navios_di.InjectionToken.create(Symbol.for("ConfigService"), ConfigServiceOptionsSchema);
1762
1708
  let _ConfigService;
1763
- _dec$11 = (0, _navios_di.Injectable)({ token: ConfigServiceToken });
1709
+ _dec$12 = (0, _navios_di.Injectable)({ token: ConfigServiceToken });
1764
1710
  (class {
1765
1711
  config;
1766
1712
  static {
1767
- ({c: [_ConfigService, _initClass$11]} = _apply_decs_2203_r$11(this, [], [_dec$11]));
1713
+ ({c: [_ConfigService, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
1768
1714
  }
1769
1715
  /**
1770
1716
  * Creates a new ConfigService instance.
@@ -1846,7 +1792,7 @@ _dec$11 = (0, _navios_di.Injectable)({ token: ConfigServiceToken });
1846
1792
  return value;
1847
1793
  }
1848
1794
  static {
1849
- _initClass$11();
1795
+ _initClass$12();
1850
1796
  }
1851
1797
  });
1852
1798
  /**
@@ -2081,6 +2027,357 @@ _dec$11 = (0, _navios_di.Injectable)({ token: ConfigServiceToken });
2081
2027
  super(409, message, error);
2082
2028
  }
2083
2029
  };
2030
+ function applyDecs2203RFactory$11() {
2031
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2032
+ return function addInitializer(initializer) {
2033
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
2034
+ assertCallable(initializer, "An initializer");
2035
+ initializers.push(initializer);
2036
+ };
2037
+ }
2038
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2039
+ var kindStr;
2040
+ switch (kind) {
2041
+ case 1:
2042
+ kindStr = "accessor";
2043
+ break;
2044
+ case 2:
2045
+ kindStr = "method";
2046
+ break;
2047
+ case 3:
2048
+ kindStr = "getter";
2049
+ break;
2050
+ case 4:
2051
+ kindStr = "setter";
2052
+ break;
2053
+ default: kindStr = "field";
2054
+ }
2055
+ var ctx = {
2056
+ kind: kindStr,
2057
+ name: isPrivate ? "#" + name : name,
2058
+ static: isStatic,
2059
+ private: isPrivate,
2060
+ metadata
2061
+ };
2062
+ var decoratorFinishedRef = { v: false };
2063
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2064
+ var get, set;
2065
+ if (kind === 0) if (isPrivate) {
2066
+ get = desc.get;
2067
+ set = desc.set;
2068
+ } else {
2069
+ get = function() {
2070
+ return this[name];
2071
+ };
2072
+ set = function(v) {
2073
+ this[name] = v;
2074
+ };
2075
+ }
2076
+ else if (kind === 2) get = function() {
2077
+ return desc.value;
2078
+ };
2079
+ else {
2080
+ if (kind === 1 || kind === 3) get = function() {
2081
+ return desc.get.call(this);
2082
+ };
2083
+ if (kind === 1 || kind === 4) set = function(v) {
2084
+ desc.set.call(this, v);
2085
+ };
2086
+ }
2087
+ ctx.access = get && set ? {
2088
+ get,
2089
+ set
2090
+ } : get ? { get } : { set };
2091
+ try {
2092
+ return dec(value, ctx);
2093
+ } finally {
2094
+ decoratorFinishedRef.v = true;
2095
+ }
2096
+ }
2097
+ function assertNotFinished(decoratorFinishedRef, fnName) {
2098
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
2099
+ }
2100
+ function assertCallable(fn, hint) {
2101
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
2102
+ }
2103
+ function assertValidReturnValue(kind, value) {
2104
+ var type = typeof value;
2105
+ if (kind === 1) {
2106
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2107
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
2108
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
2109
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
2110
+ } else if (type !== "function") {
2111
+ var hint;
2112
+ if (kind === 0) hint = "field";
2113
+ else if (kind === 10) hint = "class";
2114
+ else hint = "method";
2115
+ throw new TypeError(hint + " decorators must return a function or void 0");
2116
+ }
2117
+ }
2118
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2119
+ var decs = decInfo[0];
2120
+ var desc, init, value;
2121
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
2122
+ get: decInfo[3],
2123
+ set: decInfo[4]
2124
+ };
2125
+ else if (kind === 3) desc = { get: decInfo[3] };
2126
+ else if (kind === 4) desc = { set: decInfo[3] };
2127
+ else desc = { value: decInfo[3] };
2128
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
2129
+ if (kind === 1) value = {
2130
+ get: desc.get,
2131
+ set: desc.set
2132
+ };
2133
+ else if (kind === 2) value = desc.value;
2134
+ else if (kind === 3) value = desc.get;
2135
+ else if (kind === 4) value = desc.set;
2136
+ var newValue, get, set;
2137
+ if (typeof decs === "function") {
2138
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2139
+ if (newValue !== void 0) {
2140
+ assertValidReturnValue(kind, newValue);
2141
+ if (kind === 0) init = newValue;
2142
+ else if (kind === 1) {
2143
+ init = newValue.init;
2144
+ get = newValue.get || value.get;
2145
+ set = newValue.set || value.set;
2146
+ value = {
2147
+ get,
2148
+ set
2149
+ };
2150
+ } else value = newValue;
2151
+ }
2152
+ } else for (var i = decs.length - 1; i >= 0; i--) {
2153
+ var dec = decs[i];
2154
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2155
+ if (newValue !== void 0) {
2156
+ assertValidReturnValue(kind, newValue);
2157
+ var newInit;
2158
+ if (kind === 0) newInit = newValue;
2159
+ else if (kind === 1) {
2160
+ newInit = newValue.init;
2161
+ get = newValue.get || value.get;
2162
+ set = newValue.set || value.set;
2163
+ value = {
2164
+ get,
2165
+ set
2166
+ };
2167
+ } else value = newValue;
2168
+ if (newInit !== void 0) if (init === void 0) init = newInit;
2169
+ else if (typeof init === "function") init = [init, newInit];
2170
+ else init.push(newInit);
2171
+ }
2172
+ }
2173
+ if (kind === 0 || kind === 1) {
2174
+ if (init === void 0) init = function(instance, init$1) {
2175
+ return init$1;
2176
+ };
2177
+ else if (typeof init !== "function") {
2178
+ var ownInitializers = init;
2179
+ init = function(instance, init$1) {
2180
+ var value$1 = init$1;
2181
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
2182
+ return value$1;
2183
+ };
2184
+ } else {
2185
+ var originalInitializer = init;
2186
+ init = function(instance, init$1) {
2187
+ return originalInitializer.call(instance, init$1);
2188
+ };
2189
+ }
2190
+ ret.push(init);
2191
+ }
2192
+ if (kind !== 0) {
2193
+ if (kind === 1) {
2194
+ desc.get = value.get;
2195
+ desc.set = value.set;
2196
+ } else if (kind === 2) desc.value = value;
2197
+ else if (kind === 3) desc.get = value;
2198
+ else if (kind === 4) desc.set = value;
2199
+ if (isPrivate) if (kind === 1) {
2200
+ ret.push(function(instance, args) {
2201
+ return value.get.call(instance, args);
2202
+ });
2203
+ ret.push(function(instance, args) {
2204
+ return value.set.call(instance, args);
2205
+ });
2206
+ } else if (kind === 2) ret.push(value);
2207
+ else ret.push(function(instance, args) {
2208
+ return value.call(instance, args);
2209
+ });
2210
+ else Object.defineProperty(base, name, desc);
2211
+ }
2212
+ }
2213
+ function applyMemberDecs(Class, decInfos, metadata) {
2214
+ var ret = [];
2215
+ var protoInitializers;
2216
+ var staticInitializers;
2217
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
2218
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
2219
+ for (var i = 0; i < decInfos.length; i++) {
2220
+ var decInfo = decInfos[i];
2221
+ if (!Array.isArray(decInfo)) continue;
2222
+ var kind = decInfo[1];
2223
+ var name = decInfo[2];
2224
+ var isPrivate = decInfo.length > 3;
2225
+ var isStatic = kind >= 5;
2226
+ var base;
2227
+ var initializers;
2228
+ if (isStatic) {
2229
+ base = Class;
2230
+ kind = kind - 5;
2231
+ staticInitializers = staticInitializers || [];
2232
+ initializers = staticInitializers;
2233
+ } else {
2234
+ base = Class.prototype;
2235
+ protoInitializers = protoInitializers || [];
2236
+ initializers = protoInitializers;
2237
+ }
2238
+ if (kind !== 0 && !isPrivate) {
2239
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
2240
+ var existingKind = existingNonFields.get(name) || 0;
2241
+ 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);
2242
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
2243
+ else existingNonFields.set(name, true);
2244
+ }
2245
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
2246
+ }
2247
+ pushInitializers(ret, protoInitializers);
2248
+ pushInitializers(ret, staticInitializers);
2249
+ return ret;
2250
+ }
2251
+ function pushInitializers(ret, initializers) {
2252
+ if (initializers) ret.push(function(instance) {
2253
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
2254
+ return instance;
2255
+ });
2256
+ }
2257
+ function applyClassDecs(targetClass, classDecs, metadata) {
2258
+ if (classDecs.length > 0) {
2259
+ var initializers = [];
2260
+ var newClass = targetClass;
2261
+ var name = targetClass.name;
2262
+ for (var i = classDecs.length - 1; i >= 0; i--) {
2263
+ var decoratorFinishedRef = { v: false };
2264
+ try {
2265
+ var nextNewClass = classDecs[i](newClass, {
2266
+ kind: "class",
2267
+ name,
2268
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
2269
+ metadata
2270
+ });
2271
+ } finally {
2272
+ decoratorFinishedRef.v = true;
2273
+ }
2274
+ if (nextNewClass !== void 0) {
2275
+ assertValidReturnValue(10, nextNewClass);
2276
+ newClass = nextNewClass;
2277
+ }
2278
+ }
2279
+ return [defineMetadata(newClass, metadata), function() {
2280
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
2281
+ }];
2282
+ }
2283
+ }
2284
+ function defineMetadata(Class, metadata) {
2285
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
2286
+ configurable: true,
2287
+ enumerable: true,
2288
+ value: metadata
2289
+ });
2290
+ }
2291
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
2292
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
2293
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
2294
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
2295
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
2296
+ return {
2297
+ e,
2298
+ get c() {
2299
+ return applyClassDecs(targetClass, classDecs, metadata);
2300
+ }
2301
+ };
2302
+ };
2303
+ }
2304
+ function _apply_decs_2203_r$11(targetClass, memberDecs, classDecs, parentClass) {
2305
+ return (_apply_decs_2203_r$11 = applyDecs2203RFactory$11())(targetClass, memberDecs, classDecs, parentClass);
2306
+ }
2307
+ var _dec$11, _initClass$11;
2308
+ let _InstanceResolverService;
2309
+ _dec$11 = (0, _navios_di.Injectable)();
2310
+ (class {
2311
+ static {
2312
+ ({c: [_InstanceResolverService, _initClass$11]} = _apply_decs_2203_r$11(this, [], [_dec$11]));
2313
+ }
2314
+ container = (0, _navios_di.inject)(_navios_di.Container);
2315
+ /**
2316
+ * Attempts to resolve a class instance, automatically detecting if it needs
2317
+ * request scope based on its dependencies.
2318
+ *
2319
+ * @param classType - The class to resolve
2320
+ * @returns A resolution result containing either a cached instance or resolver function
2321
+ */ async resolve(classType) {
2322
+ let cachedInstance = null;
2323
+ try {
2324
+ cachedInstance = await this.container.get(classType);
2325
+ } catch {
2326
+ const token = (0, _navios_di.getInjectableToken)(classType);
2327
+ this.container.getRegistry().updateScope(token, _navios_di.InjectableScope.Request);
2328
+ }
2329
+ return {
2330
+ cached: cachedInstance !== null,
2331
+ instance: cachedInstance,
2332
+ resolve: (scoped) => scoped.get(classType)
2333
+ };
2334
+ }
2335
+ /**
2336
+ * Attempts to resolve multiple class instances, automatically detecting if any need
2337
+ * request scope based on their dependencies.
2338
+ *
2339
+ * Returns `cached: true` only if ALL classes can be resolved as singletons.
2340
+ * If any class has request-scoped dependencies, returns `cached: false`.
2341
+ *
2342
+ * @param classTypes - The classes to resolve
2343
+ * @returns A resolution result containing either all cached instances or resolver function
2344
+ */ async resolveMany(classTypes) {
2345
+ if (classTypes.length === 0) return {
2346
+ cached: true,
2347
+ instances: [],
2348
+ classTypes: [],
2349
+ resolve: async () => []
2350
+ };
2351
+ const results = await Promise.all(classTypes.map(async (classType) => {
2352
+ try {
2353
+ return {
2354
+ success: true,
2355
+ instance: await this.container.get(classType)
2356
+ };
2357
+ } catch {
2358
+ const token = (0, _navios_di.getInjectableToken)(classType);
2359
+ this.container.getRegistry().updateScope(token, _navios_di.InjectableScope.Request);
2360
+ return {
2361
+ success: false,
2362
+ instance: null
2363
+ };
2364
+ }
2365
+ }));
2366
+ const allCached = results.every((r) => r.success);
2367
+ return {
2368
+ cached: allCached,
2369
+ instances: allCached ? results.map((r) => r.instance) : null,
2370
+ classTypes,
2371
+ resolve: (scoped) => Promise.all(classTypes.map((classType) => scoped.get(classType)))
2372
+ };
2373
+ }
2374
+ static {
2375
+ _initClass$11();
2376
+ }
2377
+ });
2378
+ /**
2379
+ * @deprecated Use InstanceResolverService instead
2380
+ */ const ControllerResolverService = _InstanceResolverService;
2084
2381
  function applyDecs2203RFactory$10() {
2085
2382
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2086
2383
  return function addInitializer(initializer) {
@@ -2366,23 +2663,40 @@ _dec$10 = (0, _navios_di.Injectable)();
2366
2663
  ({c: [_GuardRunnerService, _initClass$10]} = _apply_decs_2203_r$10(this, [], [_dec$10]));
2367
2664
  }
2368
2665
  logger = (0, _navios_di.inject)(Logger, { context: _GuardRunnerService.name });
2369
- async runGuards(allGuards, executionContext, context) {
2370
- let canActivate = true;
2371
- for (const guard of Array.from(allGuards).reverse()) {
2666
+ /**
2667
+ * Runs guards that need to be resolved from a scoped container.
2668
+ * Use this when guards have request-scoped dependencies.
2669
+ */ async runGuards(allGuards, executionContext, context) {
2670
+ const guardsArray = Array.from(allGuards).reverse();
2671
+ const guardInstances = await Promise.all(guardsArray.map(async (guard) => {
2372
2672
  const guardInstance = await context.get(guard);
2373
2673
  if (!guardInstance.canActivate) throw new Error(`[Navios] Guard ${guard.name} does not implement canActivate()`);
2374
- try {
2375
- canActivate = await guardInstance.canActivate(executionContext);
2376
- if (!canActivate) break;
2377
- } catch (error) {
2378
- if (error instanceof HttpException) {
2379
- executionContext.getReply().status(error.statusCode).send(error.response);
2380
- return false;
2381
- } else {
2382
- this.logger.error("Error running guard", error);
2383
- executionContext.getReply().status(500).send({ message: "Internal server error" });
2384
- return false;
2385
- }
2674
+ return guardInstance;
2675
+ }));
2676
+ return this.executeGuards(guardInstances, executionContext);
2677
+ }
2678
+ /**
2679
+ * Runs pre-resolved guard instances.
2680
+ * Use this when all guards are singletons and have been pre-resolved at startup.
2681
+ */ async runGuardsStatic(guardInstances, executionContext) {
2682
+ return this.executeGuards(guardInstances, executionContext);
2683
+ }
2684
+ /**
2685
+ * Shared guard execution logic.
2686
+ * Iterates through guard instances and calls canActivate on each.
2687
+ */ async executeGuards(guardInstances, executionContext) {
2688
+ let canActivate = true;
2689
+ for (const guardInstance of guardInstances) try {
2690
+ canActivate = await guardInstance.canActivate(executionContext);
2691
+ if (!canActivate) break;
2692
+ } catch (error) {
2693
+ if (error instanceof HttpException) {
2694
+ executionContext.getReply().status(error.statusCode).send(error.response);
2695
+ return false;
2696
+ } else {
2697
+ this.logger.error("Error running guard", error);
2698
+ executionContext.getReply().status(500).send({ message: "Internal server error" });
2699
+ return false;
2386
2700
  }
2387
2701
  }
2388
2702
  if (!canActivate) {
@@ -2699,6 +3013,49 @@ _dec$9 = (0, _navios_di.Injectable)();
2699
3013
  await this.traverseModules(appModule);
2700
3014
  this.initialized = true;
2701
3015
  }
3016
+ /**
3017
+ * Extends the module tree with additional modules or controllers.
3018
+ *
3019
+ * This method is designed to be called by plugins during registration,
3020
+ * which happens after initial module loading but before route registration.
3021
+ *
3022
+ * @param extensions - Array of module extensions to add
3023
+ * @throws Error if not initialized (loadModules must be called first)
3024
+ *
3025
+ * @example
3026
+ * ```typescript
3027
+ * // In plugin registration
3028
+ * const moduleLoader = await context.container.get(ModuleLoaderService)
3029
+ * await moduleLoader.extendModules([{
3030
+ * controllers: [OpenApiJsonController, OpenApiYamlController],
3031
+ * moduleName: 'OpenApiBunModule',
3032
+ * }])
3033
+ * ```
3034
+ */ async extendModules(extensions) {
3035
+ if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
3036
+ for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
3037
+ else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
3038
+ else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
3039
+ }
3040
+ /**
3041
+ * Registers controllers under a synthetic module.
3042
+ * Used when plugins want to add controllers without a full module class.
3043
+ */ async registerControllers(controllers, moduleName) {
3044
+ if (this.modulesMetadata.has(moduleName)) {
3045
+ const existing = this.modulesMetadata.get(moduleName);
3046
+ for (const controller of controllers) existing.controllers.add(controller);
3047
+ this.logger.debug(`Extended module ${moduleName} with ${controllers.length} controllers`);
3048
+ } else {
3049
+ const metadata = {
3050
+ controllers: new Set(controllers),
3051
+ imports: /* @__PURE__ */ new Set(),
3052
+ guards: /* @__PURE__ */ new Set(),
3053
+ customAttributes: /* @__PURE__ */ new Map()
3054
+ };
3055
+ this.modulesMetadata.set(moduleName, metadata);
3056
+ this.logger.debug(`Created module ${moduleName} with ${controllers.length} controllers`);
3057
+ }
3058
+ }
2702
3059
  async traverseModules(module$1, parentMetadata) {
2703
3060
  const metadata = extractModuleMetadata(module$1);
2704
3061
  if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
@@ -5175,7 +5532,7 @@ _dec$1$1 = (0, _navios_di.Factory)({ token: XmlStreamAdapterToken });
5175
5532
  _initClass$1$1();
5176
5533
  }
5177
5534
  });
5178
- function applyDecs2203RFactory$14() {
5535
+ function applyDecs2203RFactory$15() {
5179
5536
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
5180
5537
  return function addInitializer(initializer) {
5181
5538
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -5449,15 +5806,15 @@ function applyDecs2203RFactory$14() {
5449
5806
  };
5450
5807
  };
5451
5808
  }
5452
- function _apply_decs_2203_r$14(targetClass, memberDecs, classDecs, parentClass) {
5453
- return (_apply_decs_2203_r$14 = applyDecs2203RFactory$14())(targetClass, memberDecs, classDecs, parentClass);
5809
+ function _apply_decs_2203_r$15(targetClass, memberDecs, classDecs, parentClass) {
5810
+ return (_apply_decs_2203_r$15 = applyDecs2203RFactory$15())(targetClass, memberDecs, classDecs, parentClass);
5454
5811
  }
5455
- var _dec$14, _initClass$14;
5812
+ var _dec$15, _initClass$15;
5456
5813
  let _NaviosApplication;
5457
- _dec$14 = (0, _navios_di.Injectable)();
5814
+ _dec$15 = (0, _navios_di.Injectable)();
5458
5815
  (class {
5459
5816
  static {
5460
- ({c: [_NaviosApplication, _initClass$14]} = _apply_decs_2203_r$14(this, [], [_dec$14]));
5817
+ ({c: [_NaviosApplication, _initClass$15]} = _apply_decs_2203_r$15(this, [], [_dec$15]));
5461
5818
  }
5462
5819
  environment = (0, _navios_di.inject)(_NaviosEnvironment);
5463
5820
  moduleLoader = (0, _navios_di.inject)(_ModuleLoaderService);
@@ -5474,7 +5831,7 @@ _dec$14 = (0, _navios_di.Injectable)();
5474
5831
  /**
5475
5832
  * Sets up the application with the provided module and options.
5476
5833
  * This is called automatically by NaviosFactory.create().
5477
- *
5834
+ *
5478
5835
  * @param appModule - The root application module
5479
5836
  * @param options - Application configuration options
5480
5837
  * @internal
@@ -5485,7 +5842,7 @@ _dec$14 = (0, _navios_di.Injectable)();
5485
5842
  }
5486
5843
  /**
5487
5844
  * Gets the dependency injection container used by this application.
5488
- *
5845
+ *
5489
5846
  * @returns The Container instance
5490
5847
  */ getContainer() {
5491
5848
  return this.container;
@@ -5537,8 +5894,8 @@ _dec$14 = (0, _navios_di.Injectable)();
5537
5894
  if (!this.appModule) throw new Error("App module is not set. Call setAppModule() first.");
5538
5895
  await this.moduleLoader.loadModules(this.appModule);
5539
5896
  if (this.environment.hasHttpSetup()) await this.httpApplication?.setupHttpServer(this.options);
5540
- await this.initModules();
5541
5897
  await this.initPlugins();
5898
+ await this.initModules();
5542
5899
  if (this.environment.hasHttpSetup()) await this.httpApplication?.ready();
5543
5900
  this.isInitialized = true;
5544
5901
  this.logger.debug("Navios application initialized");
@@ -5549,11 +5906,16 @@ _dec$14 = (0, _navios_di.Injectable)();
5549
5906
  }
5550
5907
  async initPlugins() {
5551
5908
  if (this.plugins.length === 0) return;
5909
+ let server = null;
5910
+ try {
5911
+ server = this.httpApplication?.getServer() ?? null;
5912
+ } catch {}
5552
5913
  const context = {
5553
5914
  modules: this.moduleLoader.getAllModules(),
5554
- server: this.httpApplication?.getServer() ?? null,
5915
+ server,
5555
5916
  container: this.container,
5556
- globalPrefix: this.httpApplication?.getGlobalPrefix() ?? ""
5917
+ globalPrefix: this.httpApplication?.getGlobalPrefix() ?? "",
5918
+ moduleLoader: this.moduleLoader
5557
5919
  };
5558
5920
  for (const { plugin, options } of this.plugins) {
5559
5921
  this.logger.debug(`Initializing plugin: ${plugin.name}`);
@@ -5562,10 +5924,10 @@ _dec$14 = (0, _navios_di.Injectable)();
5562
5924
  }
5563
5925
  /**
5564
5926
  * Enables CORS (Cross-Origin Resource Sharing) for the application.
5565
- *
5927
+ *
5566
5928
  * @param options - CORS configuration options (adapter-specific)
5567
5929
  * @throws Error if HTTP application is not set
5568
- *
5930
+ *
5569
5931
  * @example
5570
5932
  * ```typescript
5571
5933
  * app.enableCors({
@@ -5580,10 +5942,10 @@ _dec$14 = (0, _navios_di.Injectable)();
5580
5942
  }
5581
5943
  /**
5582
5944
  * Enables multipart/form-data support for file uploads.
5583
- *
5945
+ *
5584
5946
  * @param options - Multipart configuration options (adapter-specific)
5585
5947
  * @throws Error if HTTP application is not set
5586
- *
5948
+ *
5587
5949
  * @example
5588
5950
  * ```typescript
5589
5951
  * app.enableMultipart({
@@ -5598,10 +5960,10 @@ _dec$14 = (0, _navios_di.Injectable)();
5598
5960
  }
5599
5961
  /**
5600
5962
  * Sets a global prefix for all routes.
5601
- *
5963
+ *
5602
5964
  * @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
5603
5965
  * @throws Error if HTTP application is not set
5604
- *
5966
+ *
5605
5967
  * @example
5606
5968
  * ```typescript
5607
5969
  * app.setGlobalPrefix('/api/v1')
@@ -5613,14 +5975,14 @@ _dec$14 = (0, _navios_di.Injectable)();
5613
5975
  }
5614
5976
  /**
5615
5977
  * Gets the underlying HTTP server instance.
5616
- *
5978
+ *
5617
5979
  * The type of the returned server depends on the adapter used:
5618
5980
  * - Fastify adapter: Returns FastifyInstance
5619
5981
  * - Bun adapter: Returns Bun.Server
5620
- *
5982
+ *
5621
5983
  * @returns The HTTP server instance
5622
5984
  * @throws Error if HTTP application is not set
5623
- *
5985
+ *
5624
5986
  * @example
5625
5987
  * ```typescript
5626
5988
  * const server = app.getServer()
@@ -5632,10 +5994,10 @@ _dec$14 = (0, _navios_di.Injectable)();
5632
5994
  }
5633
5995
  /**
5634
5996
  * Starts the HTTP server and begins listening for requests.
5635
- *
5997
+ *
5636
5998
  * @param options - Listen options (port, host, etc.)
5637
5999
  * @throws Error if HTTP application is not set
5638
- *
6000
+ *
5639
6001
  * @example
5640
6002
  * ```typescript
5641
6003
  * await app.listen({ port: 3000, host: '0.0.0.0' })
@@ -5646,7 +6008,7 @@ _dec$14 = (0, _navios_di.Injectable)();
5646
6008
  }
5647
6009
  /**
5648
6010
  * Disposes of application resources.
5649
- *
6011
+ *
5650
6012
  * Cleans up the HTTP server and module loader.
5651
6013
  * This method is called automatically by `close()`.
5652
6014
  */ async dispose() {
@@ -5655,9 +6017,9 @@ _dec$14 = (0, _navios_di.Injectable)();
5655
6017
  }
5656
6018
  /**
5657
6019
  * Closes the application and cleans up all resources.
5658
- *
6020
+ *
5659
6021
  * This is an alias for `dispose()`.
5660
- *
6022
+ *
5661
6023
  * @example
5662
6024
  * ```typescript
5663
6025
  * // Graceful shutdown
@@ -5670,36 +6032,36 @@ _dec$14 = (0, _navios_di.Injectable)();
5670
6032
  await this.dispose();
5671
6033
  }
5672
6034
  static {
5673
- _initClass$14();
6035
+ _initClass$15();
5674
6036
  }
5675
6037
  });
5676
6038
  /**
5677
6039
  * Factory class for creating and configuring Navios applications.
5678
- *
6040
+ *
5679
6041
  * This is the main entry point for bootstrapping a Navios application.
5680
6042
  * It handles dependency injection container setup, adapter registration,
5681
6043
  * and logger configuration.
5682
- *
6044
+ *
5683
6045
  * @example
5684
6046
  * ```typescript
5685
6047
  * import { NaviosFactory } from '@navios/core'
5686
6048
  * import { defineFastifyEnvironment } from '@navios/adapter-fastify'
5687
- *
6049
+ *
5688
6050
  * const app = await NaviosFactory.create(AppModule, {
5689
6051
  * adapter: defineFastifyEnvironment(),
5690
6052
  * logger: ['log', 'error', 'warn'],
5691
6053
  * })
5692
- *
6054
+ *
5693
6055
  * await app.init()
5694
6056
  * await app.listen({ port: 3000 })
5695
6057
  * ```
5696
6058
  */ var NaviosFactory = class {
5697
6059
  /**
5698
6060
  * Creates a new Navios application instance.
5699
- *
6061
+ *
5700
6062
  * This method sets up the dependency injection container, registers the HTTP adapter,
5701
6063
  * configures logging, and initializes the application with the provided module.
5702
- *
6064
+ *
5703
6065
  * @param appModule - The root application module class decorated with @Module()
5704
6066
  * @param options - Configuration options for the application
5705
6067
  * @param options.adapter - HTTP adapter environment (required for HTTP server functionality)
@@ -5709,20 +6071,20 @@ _dec$14 = (0, _navios_di.Injectable)();
5709
6071
  * - `false` to disable logging
5710
6072
  * @param options.container - Optional custom dependency injection container (useful for testing)
5711
6073
  * @returns A configured NaviosApplication instance ready to be initialized
5712
- *
6074
+ *
5713
6075
  * @example
5714
6076
  * ```typescript
5715
6077
  * // Basic setup with Fastify adapter
5716
6078
  * const app = await NaviosFactory.create(AppModule, {
5717
6079
  * adapter: defineFastifyEnvironment(),
5718
6080
  * })
5719
- *
6081
+ *
5720
6082
  * // With custom logger configuration
5721
6083
  * const app = await NaviosFactory.create(AppModule, {
5722
6084
  * adapter: defineFastifyEnvironment(),
5723
6085
  * logger: ['error', 'warn', 'log'],
5724
6086
  * })
5725
- *
6087
+ *
5726
6088
  * // With custom container for testing
5727
6089
  * const container = new Container()
5728
6090
  * const app = await NaviosFactory.create(AppModule, {
@@ -5732,6 +6094,8 @@ _dec$14 = (0, _navios_di.Injectable)();
5732
6094
  * ```
5733
6095
  */ static async create(appModule, options = { adapter: [] }) {
5734
6096
  const container = options.container ?? new _navios_di.Container();
6097
+ if (options.enableRequestId === true) setRequestIdEnabled(true);
6098
+ container.getServiceLocator().getManager().storeCreatedHolder(NaviosOptionsToken.toString(), options, _navios_di.InjectableType.Class, _navios_di.InjectableScope.Singleton);
5735
6099
  await this.registerLoggerConfiguration(container, options);
5736
6100
  const adapters = Array.isArray(options.adapter) ? options.adapter : [options.adapter];
5737
6101
  for (const adapter of adapters) await this.registerEnvironment(container, adapter);
@@ -5746,7 +6110,10 @@ _dec$14 = (0, _navios_di.Injectable)();
5746
6110
  }
5747
6111
  static async registerLoggerConfiguration(container, options) {
5748
6112
  const { logger } = options;
5749
- if (Array.isArray(logger) || isNil(logger)) (await container.get(LoggerOutput))?.setup({ logLevels: logger });
6113
+ if (Array.isArray(logger) || isNil(logger)) {
6114
+ (await container.get(LoggerOutput))?.setup({ logLevels: logger });
6115
+ return;
6116
+ }
5750
6117
  if (logger !== true && !isNil(logger)) container.getServiceLocator().getManager().storeCreatedHolder(LoggerOutput.toString(), logger, _navios_di.InjectableType.Class, _navios_di.InjectableScope.Singleton);
5751
6118
  }
5752
6119
  };
@@ -5764,6 +6131,7 @@ var lib_exports = /* @__PURE__ */ __export({
5764
6131
  ConsoleLogger: () => _ConsoleLogger,
5765
6132
  Controller: () => Controller,
5766
6133
  ControllerMetadataKey: () => ControllerMetadataKey,
6134
+ ControllerResolverService: () => ControllerResolverService,
5767
6135
  Endpoint: () => Endpoint,
5768
6136
  EndpointAdapterFactory: () => _EndpointAdapterFactory,
5769
6137
  EndpointAdapterToken: () => EndpointAdapterToken,
@@ -5778,6 +6146,7 @@ var lib_exports = /* @__PURE__ */ __export({
5778
6146
  HttpAdapterToken: () => HttpAdapterToken,
5779
6147
  HttpCode: () => HttpCode,
5780
6148
  HttpException: () => HttpException,
6149
+ InstanceResolverService: () => _InstanceResolverService,
5781
6150
  InternalServerErrorException: () => InternalServerErrorException,
5782
6151
  LOG_LEVELS: () => LOG_LEVELS,
5783
6152
  Logger: () => Logger,
@@ -5791,6 +6160,7 @@ var lib_exports = /* @__PURE__ */ __export({
5791
6160
  MultipartAdapterToken: () => MultipartAdapterToken,
5792
6161
  NaviosApplication: () => _NaviosApplication,
5793
6162
  NaviosFactory: () => NaviosFactory,
6163
+ NaviosOptionsToken: () => NaviosOptionsToken,
5794
6164
  NotFoundException: () => NotFoundException,
5795
6165
  Reply: () => Reply,
5796
6166
  ReplyFactory: () => _ReplyFactory,
@@ -5810,6 +6180,7 @@ var lib_exports = /* @__PURE__ */ __export({
5810
6180
  extractControllerMetadata: () => extractControllerMetadata,
5811
6181
  extractModuleMetadata: () => extractModuleMetadata,
5812
6182
  filterLogLevels: () => filterLogLevels,
6183
+ generateRequestId: () => generateRequestId,
5813
6184
  getAllEndpointMetadata: () => getAllEndpointMetadata,
5814
6185
  getControllerMetadata: () => getControllerMetadata,
5815
6186
  getEndpointMetadata: () => getEndpointMetadata,
@@ -5832,8 +6203,8 @@ var lib_exports = /* @__PURE__ */ __export({
5832
6203
  loggerOptionsSchema: () => loggerOptionsSchema,
5833
6204
  normalizePath: () => normalizePath,
5834
6205
  provideConfig: () => provideConfig,
5835
- requestIdStore: () => requestIdStore,
5836
6206
  runWithRequestId: () => runWithRequestId,
6207
+ setRequestIdEnabled: () => setRequestIdEnabled,
5837
6208
  stripEndSlash: () => stripEndSlash,
5838
6209
  yellow: () => yellow
5839
6210
  });
@@ -7482,6 +7853,7 @@ var src_exports = /* @__PURE__ */ __export({
7482
7853
  ConsoleLogger: () => _ConsoleLogger,
7483
7854
  Controller: () => Controller,
7484
7855
  ControllerMetadataKey: () => ControllerMetadataKey,
7856
+ ControllerResolverService: () => ControllerResolverService,
7485
7857
  Endpoint: () => Endpoint,
7486
7858
  EndpointAdapterFactory: () => _EndpointAdapterFactory,
7487
7859
  EndpointAdapterToken: () => EndpointAdapterToken,
@@ -7496,6 +7868,7 @@ var src_exports = /* @__PURE__ */ __export({
7496
7868
  HttpAdapterToken: () => HttpAdapterToken,
7497
7869
  HttpCode: () => HttpCode,
7498
7870
  HttpException: () => HttpException,
7871
+ InstanceResolverService: () => _InstanceResolverService,
7499
7872
  InternalServerErrorException: () => InternalServerErrorException,
7500
7873
  LOG_LEVELS: () => LOG_LEVELS,
7501
7874
  Logger: () => Logger,
@@ -7509,6 +7882,7 @@ var src_exports = /* @__PURE__ */ __export({
7509
7882
  MultipartAdapterToken: () => MultipartAdapterToken,
7510
7883
  NaviosApplication: () => _NaviosApplication,
7511
7884
  NaviosFactory: () => NaviosFactory,
7885
+ NaviosOptionsToken: () => NaviosOptionsToken,
7512
7886
  NotFoundException: () => NotFoundException,
7513
7887
  Reply: () => Reply,
7514
7888
  ReplyFactory: () => _ReplyFactory,
@@ -7530,6 +7904,7 @@ var src_exports = /* @__PURE__ */ __export({
7530
7904
  extractControllerMetadata: () => extractControllerMetadata,
7531
7905
  extractModuleMetadata: () => extractModuleMetadata,
7532
7906
  filterLogLevels: () => filterLogLevels,
7907
+ generateRequestId: () => generateRequestId,
7533
7908
  getAllEndpointMetadata: () => getAllEndpointMetadata,
7534
7909
  getCliModuleMetadata: () => getCliModuleMetadata,
7535
7910
  getCommandMetadata: () => getCommandMetadata,
@@ -7556,8 +7931,8 @@ var src_exports = /* @__PURE__ */ __export({
7556
7931
  loggerOptionsSchema: () => loggerOptionsSchema,
7557
7932
  normalizePath: () => normalizePath,
7558
7933
  provideConfig: () => provideConfig,
7559
- requestIdStore: () => requestIdStore,
7560
7934
  runWithRequestId: () => runWithRequestId,
7935
+ setRequestIdEnabled: () => setRequestIdEnabled,
7561
7936
  stripEndSlash: () => stripEndSlash,
7562
7937
  yellow: () => yellow
7563
7938
  });
@@ -7609,6 +7984,7 @@ Object.defineProperty(exports, 'ConsoleLogger', {
7609
7984
  });
7610
7985
  exports.Controller = Controller;
7611
7986
  exports.ControllerMetadataKey = ControllerMetadataKey;
7987
+ exports.ControllerResolverService = ControllerResolverService;
7612
7988
  exports.Endpoint = Endpoint;
7613
7989
  Object.defineProperty(exports, 'EndpointAdapterFactory', {
7614
7990
  enumerable: true,
@@ -7638,6 +8014,12 @@ Object.defineProperty(exports, 'HttpAdapterFactory', {
7638
8014
  exports.HttpAdapterToken = HttpAdapterToken;
7639
8015
  exports.HttpCode = HttpCode;
7640
8016
  exports.HttpException = HttpException;
8017
+ Object.defineProperty(exports, 'InstanceResolverService', {
8018
+ enumerable: true,
8019
+ get: function () {
8020
+ return _InstanceResolverService;
8021
+ }
8022
+ });
7641
8023
  exports.InternalServerErrorException = InternalServerErrorException;
7642
8024
  exports.LOG_LEVELS = LOG_LEVELS;
7643
8025
  exports.Logger = Logger;
@@ -7671,6 +8053,7 @@ Object.defineProperty(exports, 'NaviosApplication', {
7671
8053
  }
7672
8054
  });
7673
8055
  exports.NaviosFactory = NaviosFactory;
8056
+ exports.NaviosOptionsToken = NaviosOptionsToken;
7674
8057
  exports.NotFoundException = NotFoundException;
7675
8058
  exports.Reply = Reply;
7676
8059
  Object.defineProperty(exports, 'ReplyFactory', {
@@ -7712,6 +8095,7 @@ exports.extractCommandMetadata = extractCommandMetadata;
7712
8095
  exports.extractControllerMetadata = extractControllerMetadata;
7713
8096
  exports.extractModuleMetadata = extractModuleMetadata;
7714
8097
  exports.filterLogLevels = filterLogLevels;
8098
+ exports.generateRequestId = generateRequestId;
7715
8099
  exports.getAllEndpointMetadata = getAllEndpointMetadata;
7716
8100
  exports.getCliModuleMetadata = getCliModuleMetadata;
7717
8101
  exports.getCommandMetadata = getCommandMetadata;
@@ -7738,8 +8122,8 @@ exports.isUndefined = isUndefined;
7738
8122
  exports.loggerOptionsSchema = loggerOptionsSchema;
7739
8123
  exports.normalizePath = normalizePath;
7740
8124
  exports.provideConfig = provideConfig;
7741
- exports.requestIdStore = requestIdStore;
7742
8125
  exports.runWithRequestId = runWithRequestId;
8126
+ exports.setRequestIdEnabled = setRequestIdEnabled;
7743
8127
  exports.stripEndSlash = stripEndSlash;
7744
8128
  exports.yellow = yellow;
7745
8129
  Object.keys(_navios_di).forEach(function (k) {