@navios/core 0.7.0 → 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.
Files changed (234) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/lib/{index-BFwNx9WQ.d.cts → index-BDNl7j1G.d.cts} +666 -292
  3. package/lib/index-BDNl7j1G.d.cts.map +1 -0
  4. package/lib/{index-D657ijFO.d.mts → index-BoP0cWT6.d.mts} +666 -292
  5. package/lib/index-BoP0cWT6.d.mts.map +1 -0
  6. package/lib/index.cjs +15 -6
  7. package/lib/index.d.cts +2 -2
  8. package/lib/index.d.mts +2 -2
  9. package/lib/index.mjs +3 -3
  10. package/lib/legacy-compat/index.cjs +1 -1
  11. package/lib/legacy-compat/index.cjs.map +1 -1
  12. package/lib/legacy-compat/index.d.cts +1 -1
  13. package/lib/legacy-compat/index.d.cts.map +1 -1
  14. package/lib/legacy-compat/index.d.mts +1 -1
  15. package/lib/legacy-compat/index.d.mts.map +1 -1
  16. package/lib/legacy-compat/index.mjs +1 -1
  17. package/lib/legacy-compat/index.mjs.map +1 -1
  18. package/lib/{src-Cb1aTjl0.cjs → src-B6eISODM.cjs} +622 -114
  19. package/lib/src-B6eISODM.cjs.map +1 -0
  20. package/lib/{src-DzPY5s6d.mjs → src-gBAChVRL.mjs} +563 -73
  21. package/lib/src-gBAChVRL.mjs.map +1 -0
  22. package/lib/testing/index.cjs +6 -6
  23. package/lib/testing/index.cjs.map +1 -1
  24. package/lib/testing/index.d.cts +1 -1
  25. package/lib/testing/index.d.mts +1 -1
  26. package/lib/testing/index.mjs +2 -2
  27. package/lib/{use-guards.decorator-DdvUhB03.cjs → use-guards.decorator-COR-9mZY.cjs} +34 -108
  28. package/lib/use-guards.decorator-COR-9mZY.cjs.map +1 -0
  29. package/lib/{use-guards.decorator-kZ3lNK8v.mjs → use-guards.decorator-CUww54Nt.mjs} +14 -94
  30. package/lib/use-guards.decorator-CUww54Nt.mjs.map +1 -0
  31. package/package.json +12 -12
  32. package/src/__tests__/controller-resolver.spec.mts +223 -0
  33. package/src/__tests__/controller.spec.mts +1 -1
  34. package/src/decorators/controller.decorator.mts +11 -6
  35. package/src/decorators/endpoint.decorator.mts +60 -12
  36. package/src/decorators/multipart.decorator.mts +67 -24
  37. package/src/decorators/stream.decorator.mts +65 -24
  38. package/src/interfaces/abstract-http-adapter.interface.mts +52 -0
  39. package/src/interfaces/abstract-http-handler-adapter.interface.mts +31 -1
  40. package/src/interfaces/index.mts +1 -0
  41. package/src/interfaces/plugin.interface.mts +105 -0
  42. package/src/legacy-compat/decorators/endpoint.decorator.mts +1 -1
  43. package/src/legacy-compat/decorators/multipart.decorator.mts +1 -1
  44. package/src/legacy-compat/decorators/stream.decorator.mts +1 -1
  45. package/src/logger/logger.service.mts +3 -3
  46. package/src/navios.application.mts +91 -27
  47. package/src/navios.factory.mts +29 -9
  48. package/src/services/guard-runner.service.mts +46 -9
  49. package/src/services/index.mts +1 -0
  50. package/src/services/instance-resolver.service.mts +186 -0
  51. package/src/services/module-loader.service.mts +102 -1
  52. package/src/stores/request-id.store.mts +45 -3
  53. package/src/tokens/index.mts +1 -0
  54. package/src/tokens/navios-options.token.mts +6 -0
  55. package/lib/index-BFwNx9WQ.d.cts.map +0 -1
  56. package/lib/index-D657ijFO.d.mts.map +0 -1
  57. package/lib/src-Cb1aTjl0.cjs.map +0 -1
  58. package/lib/src-DzPY5s6d.mjs.map +0 -1
  59. package/lib/use-guards.decorator-DdvUhB03.cjs.map +0 -1
  60. package/lib/use-guards.decorator-kZ3lNK8v.mjs.map +0 -1
  61. package/src/attribute.factory.d.mts +0 -175
  62. package/src/attribute.factory.d.mts.map +0 -1
  63. package/src/config/config-service.interface.d.mts +0 -39
  64. package/src/config/config-service.interface.d.mts.map +0 -1
  65. package/src/config/config.provider.d.mts +0 -46
  66. package/src/config/config.provider.d.mts.map +0 -1
  67. package/src/config/config.service.d.mts +0 -108
  68. package/src/config/config.service.d.mts.map +0 -1
  69. package/src/config/index.d.mts +0 -6
  70. package/src/config/index.d.mts.map +0 -1
  71. package/src/config/types.d.mts +0 -13
  72. package/src/config/types.d.mts.map +0 -1
  73. package/src/config/utils/helpers.d.mts +0 -3
  74. package/src/config/utils/helpers.d.mts.map +0 -1
  75. package/src/config/utils/index.d.mts +0 -2
  76. package/src/config/utils/index.d.mts.map +0 -1
  77. package/src/decorators/controller.decorator.d.mts +0 -33
  78. package/src/decorators/controller.decorator.d.mts.map +0 -1
  79. package/src/decorators/endpoint.decorator.d.mts +0 -89
  80. package/src/decorators/endpoint.decorator.d.mts.map +0 -1
  81. package/src/decorators/header.decorator.d.mts +0 -22
  82. package/src/decorators/header.decorator.d.mts.map +0 -1
  83. package/src/decorators/http-code.decorator.d.mts +0 -22
  84. package/src/decorators/http-code.decorator.d.mts.map +0 -1
  85. package/src/decorators/index.d.mts +0 -9
  86. package/src/decorators/index.d.mts.map +0 -1
  87. package/src/decorators/module.decorator.d.mts +0 -42
  88. package/src/decorators/module.decorator.d.mts.map +0 -1
  89. package/src/decorators/multipart.decorator.d.mts +0 -54
  90. package/src/decorators/multipart.decorator.d.mts.map +0 -1
  91. package/src/decorators/stream.decorator.d.mts +0 -42
  92. package/src/decorators/stream.decorator.d.mts.map +0 -1
  93. package/src/decorators/use-guards.decorator.d.mts +0 -33
  94. package/src/decorators/use-guards.decorator.d.mts.map +0 -1
  95. package/src/exceptions/bad-request.exception.d.mts +0 -26
  96. package/src/exceptions/bad-request.exception.d.mts.map +0 -1
  97. package/src/exceptions/conflict.exception.d.mts +0 -29
  98. package/src/exceptions/conflict.exception.d.mts.map +0 -1
  99. package/src/exceptions/forbidden.exception.d.mts +0 -28
  100. package/src/exceptions/forbidden.exception.d.mts.map +0 -1
  101. package/src/exceptions/http.exception.d.mts +0 -33
  102. package/src/exceptions/http.exception.d.mts.map +0 -1
  103. package/src/exceptions/index.d.mts +0 -8
  104. package/src/exceptions/index.d.mts.map +0 -1
  105. package/src/exceptions/internal-server-error.exception.d.mts +0 -31
  106. package/src/exceptions/internal-server-error.exception.d.mts.map +0 -1
  107. package/src/exceptions/not-found.exception.d.mts +0 -30
  108. package/src/exceptions/not-found.exception.d.mts.map +0 -1
  109. package/src/exceptions/unauthorized.exception.d.mts +0 -28
  110. package/src/exceptions/unauthorized.exception.d.mts.map +0 -1
  111. package/src/factories/endpoint-adapter.factory.d.mts +0 -6
  112. package/src/factories/endpoint-adapter.factory.d.mts.map +0 -1
  113. package/src/factories/http-adapter.factory.d.mts +0 -6
  114. package/src/factories/http-adapter.factory.d.mts.map +0 -1
  115. package/src/factories/index.d.mts +0 -8
  116. package/src/factories/index.d.mts.map +0 -1
  117. package/src/factories/multipart-adapter.factory.d.mts +0 -6
  118. package/src/factories/multipart-adapter.factory.d.mts.map +0 -1
  119. package/src/factories/reply.factory.d.mts +0 -6
  120. package/src/factories/reply.factory.d.mts.map +0 -1
  121. package/src/factories/request.factory.d.mts +0 -6
  122. package/src/factories/request.factory.d.mts.map +0 -1
  123. package/src/factories/stream-adapter.factory.d.mts +0 -6
  124. package/src/factories/stream-adapter.factory.d.mts.map +0 -1
  125. package/src/factories/xml-stream-adapter.factory.d.mts +0 -6
  126. package/src/factories/xml-stream-adapter.factory.d.mts.map +0 -1
  127. package/src/index.d.mts +0 -15
  128. package/src/index.d.mts.map +0 -1
  129. package/src/interfaces/abstract-execution-context.inteface.d.mts +0 -44
  130. package/src/interfaces/abstract-execution-context.inteface.d.mts.map +0 -1
  131. package/src/interfaces/abstract-http-adapter.interface.d.mts +0 -15
  132. package/src/interfaces/abstract-http-adapter.interface.d.mts.map +0 -1
  133. package/src/interfaces/abstract-http-cors-options.interface.d.mts +0 -58
  134. package/src/interfaces/abstract-http-cors-options.interface.d.mts.map +0 -1
  135. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts +0 -7
  136. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts.map +0 -1
  137. package/src/interfaces/abstract-http-listen-options.interface.d.mts +0 -5
  138. package/src/interfaces/abstract-http-listen-options.interface.d.mts.map +0 -1
  139. package/src/interfaces/can-activate.d.mts +0 -36
  140. package/src/interfaces/can-activate.d.mts.map +0 -1
  141. package/src/interfaces/http-header.d.mts +0 -10
  142. package/src/interfaces/http-header.d.mts.map +0 -1
  143. package/src/interfaces/index.d.mts +0 -9
  144. package/src/interfaces/index.d.mts.map +0 -1
  145. package/src/interfaces/navios-module.d.mts +0 -29
  146. package/src/interfaces/navios-module.d.mts.map +0 -1
  147. package/src/legacy-compat/context-compat.d.mts +0 -19
  148. package/src/legacy-compat/context-compat.d.mts.map +0 -1
  149. package/src/legacy-compat/decorators/controller.decorator.d.mts +0 -21
  150. package/src/legacy-compat/decorators/controller.decorator.d.mts.map +0 -1
  151. package/src/legacy-compat/decorators/endpoint.decorator.d.mts +0 -33
  152. package/src/legacy-compat/decorators/endpoint.decorator.d.mts.map +0 -1
  153. package/src/legacy-compat/decorators/header.decorator.d.mts +0 -24
  154. package/src/legacy-compat/decorators/header.decorator.d.mts.map +0 -1
  155. package/src/legacy-compat/decorators/http-code.decorator.d.mts +0 -22
  156. package/src/legacy-compat/decorators/http-code.decorator.d.mts.map +0 -1
  157. package/src/legacy-compat/decorators/index.d.mts +0 -9
  158. package/src/legacy-compat/decorators/index.d.mts.map +0 -1
  159. package/src/legacy-compat/decorators/module.decorator.d.mts +0 -22
  160. package/src/legacy-compat/decorators/module.decorator.d.mts.map +0 -1
  161. package/src/legacy-compat/decorators/multipart.decorator.d.mts +0 -34
  162. package/src/legacy-compat/decorators/multipart.decorator.d.mts.map +0 -1
  163. package/src/legacy-compat/decorators/stream.decorator.d.mts +0 -34
  164. package/src/legacy-compat/decorators/stream.decorator.d.mts.map +0 -1
  165. package/src/legacy-compat/decorators/use-guards.decorator.d.mts +0 -29
  166. package/src/legacy-compat/decorators/use-guards.decorator.d.mts.map +0 -1
  167. package/src/legacy-compat/index.d.mts +0 -19
  168. package/src/legacy-compat/index.d.mts.map +0 -1
  169. package/src/logger/console-logger.service.d.mts +0 -196
  170. package/src/logger/console-logger.service.d.mts.map +0 -1
  171. package/src/logger/index.d.mts +0 -7
  172. package/src/logger/index.d.mts.map +0 -1
  173. package/src/logger/log-levels.d.mts +0 -14
  174. package/src/logger/log-levels.d.mts.map +0 -1
  175. package/src/logger/logger-service.interface.d.mts +0 -36
  176. package/src/logger/logger-service.interface.d.mts.map +0 -1
  177. package/src/logger/logger.service.d.mts +0 -57
  178. package/src/logger/logger.service.d.mts.map +0 -1
  179. package/src/logger/logger.tokens.d.mts +0 -36
  180. package/src/logger/logger.tokens.d.mts.map +0 -1
  181. package/src/logger/utils/cli-colors.util.d.mts +0 -10
  182. package/src/logger/utils/cli-colors.util.d.mts.map +0 -1
  183. package/src/logger/utils/filter-log-levelts.util.d.mts +0 -6
  184. package/src/logger/utils/filter-log-levelts.util.d.mts.map +0 -1
  185. package/src/logger/utils/index.d.mts +0 -6
  186. package/src/logger/utils/index.d.mts.map +0 -1
  187. package/src/logger/utils/is-log-level-enabled.d.mts +0 -8
  188. package/src/logger/utils/is-log-level-enabled.d.mts.map +0 -1
  189. package/src/logger/utils/is-log-level.util.d.mts +0 -6
  190. package/src/logger/utils/is-log-level.util.d.mts.map +0 -1
  191. package/src/logger/utils/shared.utils.d.mts +0 -14
  192. package/src/logger/utils/shared.utils.d.mts.map +0 -1
  193. package/src/metadata/controller.metadata.d.mts +0 -13
  194. package/src/metadata/controller.metadata.d.mts.map +0 -1
  195. package/src/metadata/handler.metadata.d.mts +0 -18
  196. package/src/metadata/handler.metadata.d.mts.map +0 -1
  197. package/src/metadata/index.d.mts +0 -4
  198. package/src/metadata/index.d.mts.map +0 -1
  199. package/src/metadata/module.metadata.d.mts +0 -13
  200. package/src/metadata/module.metadata.d.mts.map +0 -1
  201. package/src/navios.application.d.mts +0 -210
  202. package/src/navios.application.d.mts.map +0 -1
  203. package/src/navios.environment.d.mts +0 -11
  204. package/src/navios.environment.d.mts.map +0 -1
  205. package/src/navios.factory.d.mts +0 -68
  206. package/src/navios.factory.d.mts.map +0 -1
  207. package/src/services/guard-runner.service.d.mts +0 -10
  208. package/src/services/guard-runner.service.d.mts.map +0 -1
  209. package/src/services/index.d.mts +0 -3
  210. package/src/services/index.d.mts.map +0 -1
  211. package/src/services/module-loader.service.d.mts +0 -17
  212. package/src/services/module-loader.service.d.mts.map +0 -1
  213. package/src/stores/index.d.mts +0 -2
  214. package/src/stores/index.d.mts.map +0 -1
  215. package/src/stores/request-id.store.d.mts +0 -37
  216. package/src/stores/request-id.store.d.mts.map +0 -1
  217. package/src/tokens/endpoint-adapter.token.d.mts +0 -4
  218. package/src/tokens/endpoint-adapter.token.d.mts.map +0 -1
  219. package/src/tokens/execution-context.token.d.mts +0 -5
  220. package/src/tokens/execution-context.token.d.mts.map +0 -1
  221. package/src/tokens/http-adapter.token.d.mts +0 -4
  222. package/src/tokens/http-adapter.token.d.mts.map +0 -1
  223. package/src/tokens/index.d.mts +0 -9
  224. package/src/tokens/index.d.mts.map +0 -1
  225. package/src/tokens/multipart-adapter.token.d.mts +0 -4
  226. package/src/tokens/multipart-adapter.token.d.mts.map +0 -1
  227. package/src/tokens/reply.token.d.mts +0 -3
  228. package/src/tokens/reply.token.d.mts.map +0 -1
  229. package/src/tokens/request.token.d.mts +0 -3
  230. package/src/tokens/request.token.d.mts.map +0 -1
  231. package/src/tokens/stream-adapter.token.d.mts +0 -4
  232. package/src/tokens/stream-adapter.token.d.mts.map +0 -1
  233. package/src/tokens/xml-stream-adapter.token.d.mts +0 -4
  234. package/src/tokens/xml-stream-adapter.token.d.mts.map +0 -1
@@ -1,5 +1,5 @@
1
- import { O as getEndpointMetadata, T as hasControllerMetadata, b as getModuleMetadata, c as XmlStreamAdapterToken, d as Reply, f as MultipartAdapterToken, g as EndpointAdapterToken, l as StreamAdapterToken, p as HttpAdapterToken, u as Request, w as getControllerMetadata, x as hasModuleMetadata, y as extractModuleMetadata } from "./use-guards.decorator-kZ3lNK8v.mjs";
2
- import { Container, Factory, Injectable, InjectableScope, InjectableType, InjectionToken, inject } from "@navios/di";
1
+ import { E as hasControllerMetadata, S as hasModuleMetadata, T as getControllerMetadata, _ as EndpointAdapterToken, b as extractModuleMetadata, c as XmlStreamAdapterToken, d as Reply, f as NaviosOptionsToken, k as getEndpointMetadata, l as StreamAdapterToken, m as HttpAdapterToken, p as MultipartAdapterToken, u as Request, x as getModuleMetadata } from "./use-guards.decorator-CUww54Nt.mjs";
2
+ import { Container, Factory, Injectable, InjectableScope, InjectableType, InjectionToken, getInjectableToken, inject } from "@navios/di";
3
3
  import { env } from "node:process";
4
4
  import z, { z as z$1 } from "zod/v4";
5
5
  import { NaviosError } from "@navios/builder";
@@ -110,6 +110,15 @@ const isSymbol = (val) => typeof val === "symbol";
110
110
 
111
111
  //#endregion
112
112
  //#region src/stores/request-id.store.mts
113
+ let requestCounter = 0;
114
+ /**
115
+ * Generates a simple incremental request ID.
116
+ * Much faster than crypto.randomUUID() and sufficient for request tracking.
117
+ *
118
+ * @returns A unique request ID string (e.g., "req-1", "req-2", ...)
119
+ */ function generateRequestId() {
120
+ return `req-${++requestCounter}`;
121
+ }
113
122
  /**
114
123
  * AsyncLocalStorage store for the current request ID.
115
124
  *
@@ -129,22 +138,42 @@ const isSymbol = (val) => typeof val === "symbol";
129
138
  * // Get current request ID (returns undefined if not in a request context)
130
139
  * const currentId = getRequestId()
131
140
  * ```
132
- */ const requestIdStore = new AsyncLocalStorage();
141
+ */ let requestIdStore = null;
142
+ function getRequestIdStore() {
143
+ if (!requestIdStore) requestIdStore = new AsyncLocalStorage();
144
+ return requestIdStore;
145
+ }
146
+ /**
147
+ * Whether request ID propagation is enabled.
148
+ * When disabled, runWithRequestId is a pass-through for better performance.
149
+ */ let requestIdEnabled = false;
150
+ /**
151
+ * Enables or disables request ID propagation.
152
+ * Called by NaviosFactory based on the enableRequestId option.
153
+ *
154
+ * @param enabled - Whether to enable request ID propagation
155
+ */ function setRequestIdEnabled(enabled) {
156
+ requestIdEnabled = enabled;
157
+ }
133
158
  /**
134
159
  * Runs a function with a request ID in the async local storage context.
160
+ * If request ID propagation is disabled, the function is called directly
161
+ * without AsyncLocalStorage overhead.
135
162
  *
136
163
  * @param requestId - The request ID to set for this context
137
164
  * @param fn - The function to run within this context
138
165
  * @returns The return value of the function
139
166
  */ function runWithRequestId(requestId, fn) {
140
- return requestIdStore.run(requestId, fn);
167
+ if (!requestIdEnabled) return fn();
168
+ return getRequestIdStore().run(requestId, fn);
141
169
  }
142
170
  /**
143
171
  * Gets the current request ID from the async local storage context.
144
172
  *
145
173
  * @returns The current request ID, or undefined if not in a request context
146
174
  */ function getRequestId() {
147
- return requestIdStore.getStore();
175
+ if (!requestIdEnabled) return;
176
+ return getRequestIdStore().getStore();
148
177
  }
149
178
 
150
179
  //#endregion
@@ -172,7 +201,7 @@ const isSymbol = (val) => typeof val === "symbol";
172
201
 
173
202
  //#endregion
174
203
  //#region src/logger/console-logger.service.mts
175
- function applyDecs2203RFactory$13() {
204
+ function applyDecs2203RFactory$14() {
176
205
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
177
206
  return function addInitializer(initializer) {
178
207
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -446,10 +475,10 @@ function applyDecs2203RFactory$13() {
446
475
  };
447
476
  };
448
477
  }
449
- function _apply_decs_2203_r$13(targetClass, memberDecs, classDecs, parentClass) {
450
- return (_apply_decs_2203_r$13 = applyDecs2203RFactory$13())(targetClass, memberDecs, classDecs, parentClass);
478
+ function _apply_decs_2203_r$14(targetClass, memberDecs, classDecs, parentClass) {
479
+ return (_apply_decs_2203_r$14 = applyDecs2203RFactory$14())(targetClass, memberDecs, classDecs, parentClass);
451
480
  }
452
- var _dec$13, _initClass$13;
481
+ var _dec$14, _initClass$14;
453
482
  const DEFAULT_DEPTH = 5;
454
483
  const DEFAULT_LOG_LEVELS = [
455
484
  "log",
@@ -468,10 +497,10 @@ const dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
468
497
  month: "2-digit"
469
498
  });
470
499
  let _ConsoleLogger;
471
- _dec$13 = Injectable({ token: LoggerOutput });
500
+ _dec$14 = Injectable({ token: LoggerOutput });
472
501
  var ConsoleLogger = class {
473
502
  static {
474
- ({c: [_ConsoleLogger, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
503
+ ({c: [_ConsoleLogger, _initClass$14]} = _apply_decs_2203_r$14(this, [], [_dec$14]));
475
504
  }
476
505
  /**
477
506
  * The options of the logger.
@@ -720,13 +749,13 @@ var ConsoleLogger = class {
720
749
  }
721
750
  }
722
751
  static {
723
- _initClass$13();
752
+ _initClass$14();
724
753
  }
725
754
  };
726
755
 
727
756
  //#endregion
728
757
  //#region src/logger/logger.service.mts
729
- function applyDecs2203RFactory$12() {
758
+ function applyDecs2203RFactory$13() {
730
759
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
731
760
  return function addInitializer(initializer) {
732
761
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -1000,15 +1029,15 @@ function applyDecs2203RFactory$12() {
1000
1029
  };
1001
1030
  };
1002
1031
  }
1003
- function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass) {
1004
- return (_apply_decs_2203_r$12 = applyDecs2203RFactory$12())(targetClass, memberDecs, classDecs, parentClass);
1032
+ function _apply_decs_2203_r$13(targetClass, memberDecs, classDecs, parentClass) {
1033
+ return (_apply_decs_2203_r$13 = applyDecs2203RFactory$13())(targetClass, memberDecs, classDecs, parentClass);
1005
1034
  }
1006
- var _dec$12, _initClass$12;
1035
+ var _dec$13, _initClass$13;
1007
1036
  let _LoggerInstance;
1008
- _dec$12 = Injectable({ token: Logger });
1037
+ _dec$13 = Injectable({ token: Logger });
1009
1038
  var LoggerInstance = class {
1010
1039
  static {
1011
- ({c: [_LoggerInstance, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
1040
+ ({c: [_LoggerInstance, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
1012
1041
  }
1013
1042
  constructor(config = {}) {
1014
1043
  this.context = config.context;
@@ -1040,13 +1069,13 @@ var LoggerInstance = class {
1040
1069
  this.localInstance?.fatal?.(message, ...optionalParams);
1041
1070
  }
1042
1071
  static {
1043
- _initClass$12();
1072
+ _initClass$13();
1044
1073
  }
1045
1074
  };
1046
1075
 
1047
1076
  //#endregion
1048
1077
  //#region src/config/config.service.mts
1049
- function applyDecs2203RFactory$11() {
1078
+ function applyDecs2203RFactory$12() {
1050
1079
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1051
1080
  return function addInitializer(initializer) {
1052
1081
  assertNotFinished(decoratorFinishedRef, "addInitializer");
@@ -1320,10 +1349,10 @@ function applyDecs2203RFactory$11() {
1320
1349
  };
1321
1350
  };
1322
1351
  }
1323
- function _apply_decs_2203_r$11(targetClass, memberDecs, classDecs, parentClass) {
1324
- return (_apply_decs_2203_r$11 = applyDecs2203RFactory$11())(targetClass, memberDecs, classDecs, parentClass);
1352
+ function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass) {
1353
+ return (_apply_decs_2203_r$12 = applyDecs2203RFactory$12())(targetClass, memberDecs, classDecs, parentClass);
1325
1354
  }
1326
- var _dec$11, _initClass$11;
1355
+ var _dec$12, _initClass$12;
1327
1356
  /**
1328
1357
  * Schema for validating configuration service options.
1329
1358
  */ const ConfigServiceOptionsSchema = z$1.record(z$1.string(), z$1.unknown());
@@ -1331,11 +1360,11 @@ var _dec$11, _initClass$11;
1331
1360
  * Injection token for ConfigService.
1332
1361
  */ const ConfigServiceToken = InjectionToken.create(Symbol.for("ConfigService"), ConfigServiceOptionsSchema);
1333
1362
  let _ConfigService;
1334
- _dec$11 = Injectable({ token: ConfigServiceToken });
1363
+ _dec$12 = Injectable({ token: ConfigServiceToken });
1335
1364
  var ConfigService = class {
1336
1365
  config;
1337
1366
  static {
1338
- ({c: [_ConfigService, _initClass$11]} = _apply_decs_2203_r$11(this, [], [_dec$11]));
1367
+ ({c: [_ConfigService, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
1339
1368
  }
1340
1369
  /**
1341
1370
  * Creates a new ConfigService instance.
@@ -1417,7 +1446,7 @@ var ConfigService = class {
1417
1446
  return value;
1418
1447
  }
1419
1448
  static {
1420
- _initClass$11();
1449
+ _initClass$12();
1421
1450
  }
1422
1451
  };
1423
1452
 
@@ -1677,6 +1706,360 @@ var ConfigService = class {
1677
1706
  }
1678
1707
  };
1679
1708
 
1709
+ //#endregion
1710
+ //#region src/services/instance-resolver.service.mts
1711
+ function applyDecs2203RFactory$11() {
1712
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1713
+ return function addInitializer(initializer) {
1714
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
1715
+ assertCallable(initializer, "An initializer");
1716
+ initializers.push(initializer);
1717
+ };
1718
+ }
1719
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
1720
+ var kindStr;
1721
+ switch (kind) {
1722
+ case 1:
1723
+ kindStr = "accessor";
1724
+ break;
1725
+ case 2:
1726
+ kindStr = "method";
1727
+ break;
1728
+ case 3:
1729
+ kindStr = "getter";
1730
+ break;
1731
+ case 4:
1732
+ kindStr = "setter";
1733
+ break;
1734
+ default: kindStr = "field";
1735
+ }
1736
+ var ctx = {
1737
+ kind: kindStr,
1738
+ name: isPrivate ? "#" + name : name,
1739
+ static: isStatic,
1740
+ private: isPrivate,
1741
+ metadata
1742
+ };
1743
+ var decoratorFinishedRef = { v: false };
1744
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
1745
+ var get, set;
1746
+ if (kind === 0) if (isPrivate) {
1747
+ get = desc.get;
1748
+ set = desc.set;
1749
+ } else {
1750
+ get = function() {
1751
+ return this[name];
1752
+ };
1753
+ set = function(v) {
1754
+ this[name] = v;
1755
+ };
1756
+ }
1757
+ else if (kind === 2) get = function() {
1758
+ return desc.value;
1759
+ };
1760
+ else {
1761
+ if (kind === 1 || kind === 3) get = function() {
1762
+ return desc.get.call(this);
1763
+ };
1764
+ if (kind === 1 || kind === 4) set = function(v) {
1765
+ desc.set.call(this, v);
1766
+ };
1767
+ }
1768
+ ctx.access = get && set ? {
1769
+ get,
1770
+ set
1771
+ } : get ? { get } : { set };
1772
+ try {
1773
+ return dec(value, ctx);
1774
+ } finally {
1775
+ decoratorFinishedRef.v = true;
1776
+ }
1777
+ }
1778
+ function assertNotFinished(decoratorFinishedRef, fnName) {
1779
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
1780
+ }
1781
+ function assertCallable(fn, hint) {
1782
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
1783
+ }
1784
+ function assertValidReturnValue(kind, value) {
1785
+ var type = typeof value;
1786
+ if (kind === 1) {
1787
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1788
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
1789
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
1790
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
1791
+ } else if (type !== "function") {
1792
+ var hint;
1793
+ if (kind === 0) hint = "field";
1794
+ else if (kind === 10) hint = "class";
1795
+ else hint = "method";
1796
+ throw new TypeError(hint + " decorators must return a function or void 0");
1797
+ }
1798
+ }
1799
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
1800
+ var decs = decInfo[0];
1801
+ var desc, init, value;
1802
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
1803
+ get: decInfo[3],
1804
+ set: decInfo[4]
1805
+ };
1806
+ else if (kind === 3) desc = { get: decInfo[3] };
1807
+ else if (kind === 4) desc = { set: decInfo[3] };
1808
+ else desc = { value: decInfo[3] };
1809
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
1810
+ if (kind === 1) value = {
1811
+ get: desc.get,
1812
+ set: desc.set
1813
+ };
1814
+ else if (kind === 2) value = desc.value;
1815
+ else if (kind === 3) value = desc.get;
1816
+ else if (kind === 4) value = desc.set;
1817
+ var newValue, get, set;
1818
+ if (typeof decs === "function") {
1819
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1820
+ if (newValue !== void 0) {
1821
+ assertValidReturnValue(kind, newValue);
1822
+ if (kind === 0) init = newValue;
1823
+ else if (kind === 1) {
1824
+ init = newValue.init;
1825
+ get = newValue.get || value.get;
1826
+ set = newValue.set || value.set;
1827
+ value = {
1828
+ get,
1829
+ set
1830
+ };
1831
+ } else value = newValue;
1832
+ }
1833
+ } else for (var i = decs.length - 1; i >= 0; i--) {
1834
+ var dec = decs[i];
1835
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1836
+ if (newValue !== void 0) {
1837
+ assertValidReturnValue(kind, newValue);
1838
+ var newInit;
1839
+ if (kind === 0) newInit = newValue;
1840
+ else if (kind === 1) {
1841
+ newInit = newValue.init;
1842
+ get = newValue.get || value.get;
1843
+ set = newValue.set || value.set;
1844
+ value = {
1845
+ get,
1846
+ set
1847
+ };
1848
+ } else value = newValue;
1849
+ if (newInit !== void 0) if (init === void 0) init = newInit;
1850
+ else if (typeof init === "function") init = [init, newInit];
1851
+ else init.push(newInit);
1852
+ }
1853
+ }
1854
+ if (kind === 0 || kind === 1) {
1855
+ if (init === void 0) init = function(instance, init$1) {
1856
+ return init$1;
1857
+ };
1858
+ else if (typeof init !== "function") {
1859
+ var ownInitializers = init;
1860
+ init = function(instance, init$1) {
1861
+ var value$1 = init$1;
1862
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
1863
+ return value$1;
1864
+ };
1865
+ } else {
1866
+ var originalInitializer = init;
1867
+ init = function(instance, init$1) {
1868
+ return originalInitializer.call(instance, init$1);
1869
+ };
1870
+ }
1871
+ ret.push(init);
1872
+ }
1873
+ if (kind !== 0) {
1874
+ if (kind === 1) {
1875
+ desc.get = value.get;
1876
+ desc.set = value.set;
1877
+ } else if (kind === 2) desc.value = value;
1878
+ else if (kind === 3) desc.get = value;
1879
+ else if (kind === 4) desc.set = value;
1880
+ if (isPrivate) if (kind === 1) {
1881
+ ret.push(function(instance, args) {
1882
+ return value.get.call(instance, args);
1883
+ });
1884
+ ret.push(function(instance, args) {
1885
+ return value.set.call(instance, args);
1886
+ });
1887
+ } else if (kind === 2) ret.push(value);
1888
+ else ret.push(function(instance, args) {
1889
+ return value.call(instance, args);
1890
+ });
1891
+ else Object.defineProperty(base, name, desc);
1892
+ }
1893
+ }
1894
+ function applyMemberDecs(Class, decInfos, metadata) {
1895
+ var ret = [];
1896
+ var protoInitializers;
1897
+ var staticInitializers;
1898
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
1899
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
1900
+ for (var i = 0; i < decInfos.length; i++) {
1901
+ var decInfo = decInfos[i];
1902
+ if (!Array.isArray(decInfo)) continue;
1903
+ var kind = decInfo[1];
1904
+ var name = decInfo[2];
1905
+ var isPrivate = decInfo.length > 3;
1906
+ var isStatic = kind >= 5;
1907
+ var base;
1908
+ var initializers;
1909
+ if (isStatic) {
1910
+ base = Class;
1911
+ kind = kind - 5;
1912
+ staticInitializers = staticInitializers || [];
1913
+ initializers = staticInitializers;
1914
+ } else {
1915
+ base = Class.prototype;
1916
+ protoInitializers = protoInitializers || [];
1917
+ initializers = protoInitializers;
1918
+ }
1919
+ if (kind !== 0 && !isPrivate) {
1920
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
1921
+ var existingKind = existingNonFields.get(name) || 0;
1922
+ 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);
1923
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
1924
+ else existingNonFields.set(name, true);
1925
+ }
1926
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
1927
+ }
1928
+ pushInitializers(ret, protoInitializers);
1929
+ pushInitializers(ret, staticInitializers);
1930
+ return ret;
1931
+ }
1932
+ function pushInitializers(ret, initializers) {
1933
+ if (initializers) ret.push(function(instance) {
1934
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
1935
+ return instance;
1936
+ });
1937
+ }
1938
+ function applyClassDecs(targetClass, classDecs, metadata) {
1939
+ if (classDecs.length > 0) {
1940
+ var initializers = [];
1941
+ var newClass = targetClass;
1942
+ var name = targetClass.name;
1943
+ for (var i = classDecs.length - 1; i >= 0; i--) {
1944
+ var decoratorFinishedRef = { v: false };
1945
+ try {
1946
+ var nextNewClass = classDecs[i](newClass, {
1947
+ kind: "class",
1948
+ name,
1949
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
1950
+ metadata
1951
+ });
1952
+ } finally {
1953
+ decoratorFinishedRef.v = true;
1954
+ }
1955
+ if (nextNewClass !== void 0) {
1956
+ assertValidReturnValue(10, nextNewClass);
1957
+ newClass = nextNewClass;
1958
+ }
1959
+ }
1960
+ return [defineMetadata(newClass, metadata), function() {
1961
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
1962
+ }];
1963
+ }
1964
+ }
1965
+ function defineMetadata(Class, metadata) {
1966
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
1967
+ configurable: true,
1968
+ enumerable: true,
1969
+ value: metadata
1970
+ });
1971
+ }
1972
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
1973
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
1974
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
1975
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
1976
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
1977
+ return {
1978
+ e,
1979
+ get c() {
1980
+ return applyClassDecs(targetClass, classDecs, metadata);
1981
+ }
1982
+ };
1983
+ };
1984
+ }
1985
+ function _apply_decs_2203_r$11(targetClass, memberDecs, classDecs, parentClass) {
1986
+ return (_apply_decs_2203_r$11 = applyDecs2203RFactory$11())(targetClass, memberDecs, classDecs, parentClass);
1987
+ }
1988
+ var _dec$11, _initClass$11;
1989
+ let _InstanceResolverService;
1990
+ _dec$11 = Injectable();
1991
+ var InstanceResolverService = class {
1992
+ static {
1993
+ ({c: [_InstanceResolverService, _initClass$11]} = _apply_decs_2203_r$11(this, [], [_dec$11]));
1994
+ }
1995
+ container = inject(Container);
1996
+ /**
1997
+ * Attempts to resolve a class instance, automatically detecting if it needs
1998
+ * request scope based on its dependencies.
1999
+ *
2000
+ * @param classType - The class to resolve
2001
+ * @returns A resolution result containing either a cached instance or resolver function
2002
+ */ async resolve(classType) {
2003
+ let cachedInstance = null;
2004
+ try {
2005
+ cachedInstance = await this.container.get(classType);
2006
+ } catch {
2007
+ const token = getInjectableToken(classType);
2008
+ this.container.getRegistry().updateScope(token, InjectableScope.Request);
2009
+ }
2010
+ return {
2011
+ cached: cachedInstance !== null,
2012
+ instance: cachedInstance,
2013
+ resolve: (scoped) => scoped.get(classType)
2014
+ };
2015
+ }
2016
+ /**
2017
+ * Attempts to resolve multiple class instances, automatically detecting if any need
2018
+ * request scope based on their dependencies.
2019
+ *
2020
+ * Returns `cached: true` only if ALL classes can be resolved as singletons.
2021
+ * If any class has request-scoped dependencies, returns `cached: false`.
2022
+ *
2023
+ * @param classTypes - The classes to resolve
2024
+ * @returns A resolution result containing either all cached instances or resolver function
2025
+ */ async resolveMany(classTypes) {
2026
+ if (classTypes.length === 0) return {
2027
+ cached: true,
2028
+ instances: [],
2029
+ classTypes: [],
2030
+ resolve: async () => []
2031
+ };
2032
+ const results = await Promise.all(classTypes.map(async (classType) => {
2033
+ try {
2034
+ return {
2035
+ success: true,
2036
+ instance: await this.container.get(classType)
2037
+ };
2038
+ } catch {
2039
+ const token = getInjectableToken(classType);
2040
+ this.container.getRegistry().updateScope(token, InjectableScope.Request);
2041
+ return {
2042
+ success: false,
2043
+ instance: null
2044
+ };
2045
+ }
2046
+ }));
2047
+ const allCached = results.every((r) => r.success);
2048
+ return {
2049
+ cached: allCached,
2050
+ instances: allCached ? results.map((r) => r.instance) : null,
2051
+ classTypes,
2052
+ resolve: (scoped) => Promise.all(classTypes.map((classType) => scoped.get(classType)))
2053
+ };
2054
+ }
2055
+ static {
2056
+ _initClass$11();
2057
+ }
2058
+ };
2059
+ /**
2060
+ * @deprecated Use InstanceResolverService instead
2061
+ */ const ControllerResolverService = _InstanceResolverService;
2062
+
1680
2063
  //#endregion
1681
2064
  //#region src/services/guard-runner.service.mts
1682
2065
  function applyDecs2203RFactory$10() {
@@ -1964,23 +2347,40 @@ var GuardRunnerService = class {
1964
2347
  ({c: [_GuardRunnerService, _initClass$10]} = _apply_decs_2203_r$10(this, [], [_dec$10]));
1965
2348
  }
1966
2349
  logger = inject(Logger, { context: _GuardRunnerService.name });
1967
- async runGuards(allGuards, executionContext, context) {
1968
- let canActivate = true;
1969
- for (const guard of Array.from(allGuards).reverse()) {
2350
+ /**
2351
+ * Runs guards that need to be resolved from a scoped container.
2352
+ * Use this when guards have request-scoped dependencies.
2353
+ */ async runGuards(allGuards, executionContext, context) {
2354
+ const guardsArray = Array.from(allGuards).reverse();
2355
+ const guardInstances = await Promise.all(guardsArray.map(async (guard) => {
1970
2356
  const guardInstance = await context.get(guard);
1971
2357
  if (!guardInstance.canActivate) throw new Error(`[Navios] Guard ${guard.name} does not implement canActivate()`);
1972
- try {
1973
- canActivate = await guardInstance.canActivate(executionContext);
1974
- if (!canActivate) break;
1975
- } catch (error) {
1976
- if (error instanceof HttpException) {
1977
- executionContext.getReply().status(error.statusCode).send(error.response);
1978
- return false;
1979
- } else {
1980
- this.logger.error("Error running guard", error);
1981
- executionContext.getReply().status(500).send({ message: "Internal server error" });
1982
- return false;
1983
- }
2358
+ return guardInstance;
2359
+ }));
2360
+ return this.executeGuards(guardInstances, executionContext);
2361
+ }
2362
+ /**
2363
+ * Runs pre-resolved guard instances.
2364
+ * Use this when all guards are singletons and have been pre-resolved at startup.
2365
+ */ async runGuardsStatic(guardInstances, executionContext) {
2366
+ return this.executeGuards(guardInstances, executionContext);
2367
+ }
2368
+ /**
2369
+ * Shared guard execution logic.
2370
+ * Iterates through guard instances and calls canActivate on each.
2371
+ */ async executeGuards(guardInstances, executionContext) {
2372
+ let canActivate = true;
2373
+ for (const guardInstance of guardInstances) try {
2374
+ canActivate = await guardInstance.canActivate(executionContext);
2375
+ if (!canActivate) break;
2376
+ } catch (error) {
2377
+ if (error instanceof HttpException) {
2378
+ executionContext.getReply().status(error.statusCode).send(error.response);
2379
+ return false;
2380
+ } else {
2381
+ this.logger.error("Error running guard", error);
2382
+ executionContext.getReply().status(500).send({ message: "Internal server error" });
2383
+ return false;
1984
2384
  }
1985
2385
  }
1986
2386
  if (!canActivate) {
@@ -2300,6 +2700,49 @@ var ModuleLoaderService = class {
2300
2700
  await this.traverseModules(appModule);
2301
2701
  this.initialized = true;
2302
2702
  }
2703
+ /**
2704
+ * Extends the module tree with additional modules or controllers.
2705
+ *
2706
+ * This method is designed to be called by plugins during registration,
2707
+ * which happens after initial module loading but before route registration.
2708
+ *
2709
+ * @param extensions - Array of module extensions to add
2710
+ * @throws Error if not initialized (loadModules must be called first)
2711
+ *
2712
+ * @example
2713
+ * ```typescript
2714
+ * // In plugin registration
2715
+ * const moduleLoader = await context.container.get(ModuleLoaderService)
2716
+ * await moduleLoader.extendModules([{
2717
+ * controllers: [OpenApiJsonController, OpenApiYamlController],
2718
+ * moduleName: 'OpenApiBunModule',
2719
+ * }])
2720
+ * ```
2721
+ */ async extendModules(extensions) {
2722
+ if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
2723
+ for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
2724
+ else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
2725
+ else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
2726
+ }
2727
+ /**
2728
+ * Registers controllers under a synthetic module.
2729
+ * Used when plugins want to add controllers without a full module class.
2730
+ */ async registerControllers(controllers, moduleName) {
2731
+ if (this.modulesMetadata.has(moduleName)) {
2732
+ const existing = this.modulesMetadata.get(moduleName);
2733
+ for (const controller of controllers) existing.controllers.add(controller);
2734
+ this.logger.debug(`Extended module ${moduleName} with ${controllers.length} controllers`);
2735
+ } else {
2736
+ const metadata = {
2737
+ controllers: new Set(controllers),
2738
+ imports: /* @__PURE__ */ new Set(),
2739
+ guards: /* @__PURE__ */ new Set(),
2740
+ customAttributes: /* @__PURE__ */ new Map()
2741
+ };
2742
+ this.modulesMetadata.set(moduleName, metadata);
2743
+ this.logger.debug(`Created module ${moduleName} with ${controllers.length} controllers`);
2744
+ }
2745
+ }
2303
2746
  async traverseModules(module, parentMetadata) {
2304
2747
  const metadata = extractModuleMetadata(module);
2305
2748
  if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
@@ -5097,6 +5540,7 @@ var NaviosApplication = class {
5097
5540
  container = inject(Container);
5098
5541
  appModule = null;
5099
5542
  options = { adapter: [] };
5543
+ plugins = [];
5100
5544
  /**
5101
5545
  * Indicates whether the application has been initialized.
5102
5546
  * Set to `true` after `init()` completes successfully.
@@ -5104,7 +5548,7 @@ var NaviosApplication = class {
5104
5548
  /**
5105
5549
  * Sets up the application with the provided module and options.
5106
5550
  * This is called automatically by NaviosFactory.create().
5107
- *
5551
+ *
5108
5552
  * @param appModule - The root application module
5109
5553
  * @param options - Application configuration options
5110
5554
  * @internal
@@ -5115,24 +5559,46 @@ var NaviosApplication = class {
5115
5559
  }
5116
5560
  /**
5117
5561
  * Gets the dependency injection container used by this application.
5118
- *
5562
+ *
5119
5563
  * @returns The Container instance
5120
5564
  */ getContainer() {
5121
5565
  return this.container;
5122
5566
  }
5123
5567
  /**
5568
+ * Registers a plugin to be initialized after modules are loaded.
5569
+ *
5570
+ * Plugins are initialized in the order they are registered,
5571
+ * after all modules are loaded but before the server starts listening.
5572
+ *
5573
+ * @param definition - Plugin definition with options
5574
+ * @returns this for method chaining
5575
+ *
5576
+ * @example
5577
+ * ```typescript
5578
+ * import { defineOpenApiPlugin } from '@navios/openapi-fastify'
5579
+ *
5580
+ * app.usePlugin(defineOpenApiPlugin({
5581
+ * info: { title: 'My API', version: '1.0.0' },
5582
+ * }))
5583
+ * ```
5584
+ */ usePlugin(definition) {
5585
+ this.plugins.push(definition);
5586
+ return this;
5587
+ }
5588
+ /**
5124
5589
  * Initializes the application.
5125
- *
5590
+ *
5126
5591
  * This method:
5127
5592
  * - Loads all modules and their dependencies
5128
5593
  * - Sets up the HTTP server if an adapter is configured
5129
5594
  * - Calls onModuleInit hooks on all modules
5595
+ * - Initializes registered plugins
5130
5596
  * - Marks the application as initialized
5131
- *
5597
+ *
5132
5598
  * Must be called before `listen()`.
5133
- *
5599
+ *
5134
5600
  * @throws Error if app module is not set
5135
- *
5601
+ *
5136
5602
  * @example
5137
5603
  * ```typescript
5138
5604
  * const app = await NaviosFactory.create(AppModule, {
@@ -5145,6 +5611,7 @@ var NaviosApplication = class {
5145
5611
  if (!this.appModule) throw new Error("App module is not set. Call setAppModule() first.");
5146
5612
  await this.moduleLoader.loadModules(this.appModule);
5147
5613
  if (this.environment.hasHttpSetup()) await this.httpApplication?.setupHttpServer(this.options);
5614
+ await this.initPlugins();
5148
5615
  await this.initModules();
5149
5616
  if (this.environment.hasHttpSetup()) await this.httpApplication?.ready();
5150
5617
  this.isInitialized = true;
@@ -5154,12 +5621,30 @@ var NaviosApplication = class {
5154
5621
  const modules = this.moduleLoader.getAllModules();
5155
5622
  await this.httpApplication?.onModulesInit(modules);
5156
5623
  }
5624
+ async initPlugins() {
5625
+ if (this.plugins.length === 0) return;
5626
+ let server = null;
5627
+ try {
5628
+ server = this.httpApplication?.getServer() ?? null;
5629
+ } catch {}
5630
+ const context = {
5631
+ modules: this.moduleLoader.getAllModules(),
5632
+ server,
5633
+ container: this.container,
5634
+ globalPrefix: this.httpApplication?.getGlobalPrefix() ?? "",
5635
+ moduleLoader: this.moduleLoader
5636
+ };
5637
+ for (const { plugin, options } of this.plugins) {
5638
+ this.logger.debug(`Initializing plugin: ${plugin.name}`);
5639
+ await plugin.register(context, options);
5640
+ }
5641
+ }
5157
5642
  /**
5158
5643
  * Enables CORS (Cross-Origin Resource Sharing) for the application.
5159
- *
5644
+ *
5160
5645
  * @param options - CORS configuration options (adapter-specific)
5161
5646
  * @throws Error if HTTP application is not set
5162
- *
5647
+ *
5163
5648
  * @example
5164
5649
  * ```typescript
5165
5650
  * app.enableCors({
@@ -5174,10 +5659,10 @@ var NaviosApplication = class {
5174
5659
  }
5175
5660
  /**
5176
5661
  * Enables multipart/form-data support for file uploads.
5177
- *
5662
+ *
5178
5663
  * @param options - Multipart configuration options (adapter-specific)
5179
5664
  * @throws Error if HTTP application is not set
5180
- *
5665
+ *
5181
5666
  * @example
5182
5667
  * ```typescript
5183
5668
  * app.enableMultipart({
@@ -5192,10 +5677,10 @@ var NaviosApplication = class {
5192
5677
  }
5193
5678
  /**
5194
5679
  * Sets a global prefix for all routes.
5195
- *
5680
+ *
5196
5681
  * @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
5197
5682
  * @throws Error if HTTP application is not set
5198
- *
5683
+ *
5199
5684
  * @example
5200
5685
  * ```typescript
5201
5686
  * app.setGlobalPrefix('/api/v1')
@@ -5207,14 +5692,14 @@ var NaviosApplication = class {
5207
5692
  }
5208
5693
  /**
5209
5694
  * Gets the underlying HTTP server instance.
5210
- *
5695
+ *
5211
5696
  * The type of the returned server depends on the adapter used:
5212
5697
  * - Fastify adapter: Returns FastifyInstance
5213
5698
  * - Bun adapter: Returns Bun.Server
5214
- *
5699
+ *
5215
5700
  * @returns The HTTP server instance
5216
5701
  * @throws Error if HTTP application is not set
5217
- *
5702
+ *
5218
5703
  * @example
5219
5704
  * ```typescript
5220
5705
  * const server = app.getServer()
@@ -5226,10 +5711,10 @@ var NaviosApplication = class {
5226
5711
  }
5227
5712
  /**
5228
5713
  * Starts the HTTP server and begins listening for requests.
5229
- *
5714
+ *
5230
5715
  * @param options - Listen options (port, host, etc.)
5231
5716
  * @throws Error if HTTP application is not set
5232
- *
5717
+ *
5233
5718
  * @example
5234
5719
  * ```typescript
5235
5720
  * await app.listen({ port: 3000, host: '0.0.0.0' })
@@ -5240,7 +5725,7 @@ var NaviosApplication = class {
5240
5725
  }
5241
5726
  /**
5242
5727
  * Disposes of application resources.
5243
- *
5728
+ *
5244
5729
  * Cleans up the HTTP server and module loader.
5245
5730
  * This method is called automatically by `close()`.
5246
5731
  */ async dispose() {
@@ -5249,9 +5734,9 @@ var NaviosApplication = class {
5249
5734
  }
5250
5735
  /**
5251
5736
  * Closes the application and cleans up all resources.
5252
- *
5737
+ *
5253
5738
  * This is an alias for `dispose()`.
5254
- *
5739
+ *
5255
5740
  * @example
5256
5741
  * ```typescript
5257
5742
  * // Graceful shutdown
@@ -5272,31 +5757,31 @@ var NaviosApplication = class {
5272
5757
  //#region src/navios.factory.mts
5273
5758
  /**
5274
5759
  * Factory class for creating and configuring Navios applications.
5275
- *
5760
+ *
5276
5761
  * This is the main entry point for bootstrapping a Navios application.
5277
5762
  * It handles dependency injection container setup, adapter registration,
5278
5763
  * and logger configuration.
5279
- *
5764
+ *
5280
5765
  * @example
5281
5766
  * ```typescript
5282
5767
  * import { NaviosFactory } from '@navios/core'
5283
5768
  * import { defineFastifyEnvironment } from '@navios/adapter-fastify'
5284
- *
5769
+ *
5285
5770
  * const app = await NaviosFactory.create(AppModule, {
5286
5771
  * adapter: defineFastifyEnvironment(),
5287
5772
  * logger: ['log', 'error', 'warn'],
5288
5773
  * })
5289
- *
5774
+ *
5290
5775
  * await app.init()
5291
5776
  * await app.listen({ port: 3000 })
5292
5777
  * ```
5293
5778
  */ var NaviosFactory = class {
5294
5779
  /**
5295
5780
  * Creates a new Navios application instance.
5296
- *
5781
+ *
5297
5782
  * This method sets up the dependency injection container, registers the HTTP adapter,
5298
5783
  * configures logging, and initializes the application with the provided module.
5299
- *
5784
+ *
5300
5785
  * @param appModule - The root application module class decorated with @Module()
5301
5786
  * @param options - Configuration options for the application
5302
5787
  * @param options.adapter - HTTP adapter environment (required for HTTP server functionality)
@@ -5306,20 +5791,20 @@ var NaviosApplication = class {
5306
5791
  * - `false` to disable logging
5307
5792
  * @param options.container - Optional custom dependency injection container (useful for testing)
5308
5793
  * @returns A configured NaviosApplication instance ready to be initialized
5309
- *
5794
+ *
5310
5795
  * @example
5311
5796
  * ```typescript
5312
5797
  * // Basic setup with Fastify adapter
5313
5798
  * const app = await NaviosFactory.create(AppModule, {
5314
5799
  * adapter: defineFastifyEnvironment(),
5315
5800
  * })
5316
- *
5801
+ *
5317
5802
  * // With custom logger configuration
5318
5803
  * const app = await NaviosFactory.create(AppModule, {
5319
5804
  * adapter: defineFastifyEnvironment(),
5320
5805
  * logger: ['error', 'warn', 'log'],
5321
5806
  * })
5322
- *
5807
+ *
5323
5808
  * // With custom container for testing
5324
5809
  * const container = new Container()
5325
5810
  * const app = await NaviosFactory.create(AppModule, {
@@ -5329,6 +5814,8 @@ var NaviosApplication = class {
5329
5814
  * ```
5330
5815
  */ static async create(appModule, options = { adapter: [] }) {
5331
5816
  const container = options.container ?? new Container();
5817
+ if (options.enableRequestId === true) setRequestIdEnabled(true);
5818
+ container.getServiceLocator().getManager().storeCreatedHolder(NaviosOptionsToken.toString(), options, InjectableType.Class, InjectableScope.Singleton);
5332
5819
  await this.registerLoggerConfiguration(container, options);
5333
5820
  const adapters = Array.isArray(options.adapter) ? options.adapter : [options.adapter];
5334
5821
  for (const adapter of adapters) await this.registerEnvironment(container, adapter);
@@ -5343,11 +5830,14 @@ var NaviosApplication = class {
5343
5830
  }
5344
5831
  static async registerLoggerConfiguration(container, options) {
5345
5832
  const { logger } = options;
5346
- if (Array.isArray(logger) || isNil(logger)) (await container.get(LoggerOutput))?.setup({ logLevels: logger });
5833
+ if (Array.isArray(logger) || isNil(logger)) {
5834
+ (await container.get(LoggerOutput))?.setup({ logLevels: logger });
5835
+ return;
5836
+ }
5347
5837
  if (logger !== true && !isNil(logger)) container.getServiceLocator().getManager().storeCreatedHolder(LoggerOutput.toString(), logger, InjectableType.Class, InjectableScope.Singleton);
5348
5838
  }
5349
5839
  };
5350
5840
 
5351
5841
  //#endregion
5352
- export { envInt as $, loggerOptionsSchema as A, isObject as B, ConfigServiceOptionsSchema as C, _ConsoleLogger as D, _LoggerInstance as E, isConstructor as F, normalizePath as G, isString as H, isEmpty as I, filterLogLevels as J, stripEndSlash as K, isFunction as L, requestIdStore as M, runWithRequestId as N, Logger as O, addLeadingSlash as P, yellow as Q, isNil as R, provideConfig as S, _ConfigService as T, isSymbol as U, isPlainObject as V, isUndefined as W, LOG_LEVELS as X, isLogLevel as Y, clc as Z, ForbiddenException as _, _ReplyFactory as a, ConfigProviderOptions as b, _HttpAdapterFactory as c, _ModuleLoaderService as d, envString as et, _GuardRunnerService as f, InternalServerErrorException as g, NotFoundException as h, _StreamAdapterFactory as i, getRequestId as j, LoggerOutput as k, _EndpointAdapterFactory as l, UnauthorizedException as m, _NaviosApplication as n, _RequestFactory as o, ConflictException as p, isLogLevelEnabled as q, _XmlStreamAdapterFactory as r, _MultipartAdapterFactory as s, NaviosFactory as t, AttributeFactory as u, BadRequestException as v, ConfigServiceToken as w, EnvConfigProvider as x, HttpException as y, isNumber as z };
5353
- //# sourceMappingURL=src-DzPY5s6d.mjs.map
5842
+ export { LOG_LEVELS as $, Logger as A, isFunction as B, EnvConfigProvider as C, _ConfigService as D, ConfigServiceToken as E, runWithRequestId as F, isString as G, isNumber as H, setRequestIdEnabled as I, normalizePath as J, isSymbol as K, addLeadingSlash as L, loggerOptionsSchema as M, generateRequestId as N, _LoggerInstance as O, getRequestId as P, isLogLevel as Q, isConstructor as R, ConfigProviderOptions as S, ConfigServiceOptionsSchema as T, isObject as U, isNil as V, isPlainObject as W, isLogLevelEnabled as X, stripEndSlash as Y, filterLogLevels as Z, NotFoundException as _, _ReplyFactory as a, BadRequestException as b, _HttpAdapterFactory as c, _ModuleLoaderService as d, clc as et, _GuardRunnerService as f, UnauthorizedException as g, ConflictException as h, _StreamAdapterFactory as i, LoggerOutput as j, _ConsoleLogger as k, _EndpointAdapterFactory as l, _InstanceResolverService as m, _NaviosApplication as n, envInt as nt, _RequestFactory as o, ControllerResolverService as p, isUndefined as q, _XmlStreamAdapterFactory as r, envString as rt, _MultipartAdapterFactory as s, NaviosFactory as t, yellow as tt, AttributeFactory as u, InternalServerErrorException as v, provideConfig as w, HttpException as x, ForbiddenException as y, isEmpty as z };
5843
+ //# sourceMappingURL=src-gBAChVRL.mjs.map