@navios/core 0.6.0 → 0.7.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 (273) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +18 -1
  3. package/docs/README.md +1 -0
  4. package/docs/legacy-compat.md +320 -0
  5. package/docs/testing.md +140 -17
  6. package/lib/index-BFwNx9WQ.d.cts +1951 -0
  7. package/lib/index-BFwNx9WQ.d.cts.map +1 -0
  8. package/lib/index-D657ijFO.d.mts +1951 -0
  9. package/lib/index-D657ijFO.d.mts.map +1 -0
  10. package/lib/index.cjs +157 -0
  11. package/lib/index.d.cts +3 -0
  12. package/lib/index.d.mts +3 -190
  13. package/lib/index.mjs +4 -1459
  14. package/lib/legacy-compat/index.cjs +315 -0
  15. package/lib/legacy-compat/index.cjs.map +1 -0
  16. package/lib/legacy-compat/index.d.cts +219 -0
  17. package/lib/legacy-compat/index.d.cts.map +1 -0
  18. package/lib/legacy-compat/index.d.mts +219 -0
  19. package/lib/legacy-compat/index.d.mts.map +1 -0
  20. package/lib/legacy-compat/index.mjs +308 -0
  21. package/lib/legacy-compat/index.mjs.map +1 -0
  22. package/lib/src-Cb1aTjl0.cjs +5710 -0
  23. package/lib/src-Cb1aTjl0.cjs.map +1 -0
  24. package/lib/src-DzPY5s6d.mjs +5353 -0
  25. package/lib/src-DzPY5s6d.mjs.map +1 -0
  26. package/lib/testing/index.cjs +106 -0
  27. package/lib/testing/index.cjs.map +1 -0
  28. package/lib/testing/index.d.cts +156 -0
  29. package/lib/testing/index.d.cts.map +1 -0
  30. package/lib/testing/index.d.mts +156 -0
  31. package/lib/testing/index.d.mts.map +1 -0
  32. package/lib/testing/index.mjs +100 -0
  33. package/lib/testing/index.mjs.map +1 -0
  34. package/lib/use-guards.decorator-DdvUhB03.cjs +622 -0
  35. package/lib/use-guards.decorator-DdvUhB03.cjs.map +1 -0
  36. package/lib/use-guards.decorator-kZ3lNK8v.mjs +454 -0
  37. package/lib/use-guards.decorator-kZ3lNK8v.mjs.map +1 -0
  38. package/package.json +24 -4
  39. package/project.json +2 -2
  40. package/src/attribute.factory.d.mts +175 -0
  41. package/src/attribute.factory.d.mts.map +1 -0
  42. package/src/attribute.factory.mts +154 -0
  43. package/src/config/config-service.interface.d.mts +39 -0
  44. package/src/config/config-service.interface.d.mts.map +1 -0
  45. package/src/config/config-service.interface.mts +31 -0
  46. package/src/config/config.provider.d.mts +46 -0
  47. package/src/config/config.provider.d.mts.map +1 -0
  48. package/src/config/config.provider.mts +36 -0
  49. package/src/config/config.service.d.mts +108 -0
  50. package/src/config/config.service.d.mts.map +1 -0
  51. package/src/config/config.service.mts +94 -4
  52. package/src/config/index.d.mts +6 -0
  53. package/src/config/index.d.mts.map +1 -0
  54. package/src/config/types.d.mts +13 -0
  55. package/src/config/types.d.mts.map +1 -0
  56. package/src/config/utils/helpers.d.mts +3 -0
  57. package/src/config/utils/helpers.d.mts.map +1 -0
  58. package/src/config/utils/index.d.mts +2 -0
  59. package/src/config/utils/index.d.mts.map +1 -0
  60. package/src/decorators/controller.decorator.d.mts +33 -0
  61. package/src/decorators/controller.decorator.d.mts.map +1 -0
  62. package/src/decorators/controller.decorator.mts +28 -0
  63. package/src/decorators/endpoint.decorator.d.mts +89 -0
  64. package/src/decorators/endpoint.decorator.d.mts.map +1 -0
  65. package/src/decorators/endpoint.decorator.mts +76 -0
  66. package/src/decorators/header.decorator.d.mts +22 -0
  67. package/src/decorators/header.decorator.d.mts.map +1 -0
  68. package/src/decorators/header.decorator.mts +19 -0
  69. package/src/decorators/http-code.decorator.d.mts +22 -0
  70. package/src/decorators/http-code.decorator.d.mts.map +1 -0
  71. package/src/decorators/http-code.decorator.mts +20 -0
  72. package/src/decorators/index.d.mts +9 -0
  73. package/src/decorators/index.d.mts.map +1 -0
  74. package/src/decorators/module.decorator.d.mts +42 -0
  75. package/src/decorators/module.decorator.d.mts.map +1 -0
  76. package/src/decorators/module.decorator.mts +34 -0
  77. package/src/decorators/multipart.decorator.d.mts +54 -0
  78. package/src/decorators/multipart.decorator.d.mts.map +1 -0
  79. package/src/decorators/multipart.decorator.mts +41 -0
  80. package/src/decorators/stream.decorator.d.mts +42 -0
  81. package/src/decorators/stream.decorator.d.mts.map +1 -0
  82. package/src/decorators/stream.decorator.mts +33 -0
  83. package/src/decorators/use-guards.decorator.d.mts +33 -0
  84. package/src/decorators/use-guards.decorator.d.mts.map +1 -0
  85. package/src/decorators/use-guards.decorator.mts +29 -0
  86. package/src/exceptions/bad-request.exception.d.mts +26 -0
  87. package/src/exceptions/bad-request.exception.d.mts.map +1 -0
  88. package/src/exceptions/bad-request.exception.mts +21 -0
  89. package/src/exceptions/conflict.exception.d.mts +29 -0
  90. package/src/exceptions/conflict.exception.d.mts.map +1 -0
  91. package/src/exceptions/conflict.exception.mts +24 -0
  92. package/src/exceptions/forbidden.exception.d.mts +28 -0
  93. package/src/exceptions/forbidden.exception.d.mts.map +1 -0
  94. package/src/exceptions/forbidden.exception.mts +23 -0
  95. package/src/exceptions/http.exception.d.mts +33 -0
  96. package/src/exceptions/http.exception.d.mts.map +1 -0
  97. package/src/exceptions/http.exception.mts +26 -0
  98. package/src/exceptions/index.d.mts +8 -0
  99. package/src/exceptions/index.d.mts.map +1 -0
  100. package/src/exceptions/internal-server-error.exception.d.mts +31 -0
  101. package/src/exceptions/internal-server-error.exception.d.mts.map +1 -0
  102. package/src/exceptions/internal-server-error.exception.mts +26 -0
  103. package/src/exceptions/not-found.exception.d.mts +30 -0
  104. package/src/exceptions/not-found.exception.d.mts.map +1 -0
  105. package/src/exceptions/not-found.exception.mts +23 -0
  106. package/src/exceptions/unauthorized.exception.d.mts +28 -0
  107. package/src/exceptions/unauthorized.exception.d.mts.map +1 -0
  108. package/src/exceptions/unauthorized.exception.mts +23 -0
  109. package/src/factories/endpoint-adapter.factory.d.mts +6 -0
  110. package/src/factories/endpoint-adapter.factory.d.mts.map +1 -0
  111. package/src/factories/http-adapter.factory.d.mts +6 -0
  112. package/src/factories/http-adapter.factory.d.mts.map +1 -0
  113. package/src/factories/index.d.mts +8 -0
  114. package/src/factories/index.d.mts.map +1 -0
  115. package/src/factories/multipart-adapter.factory.d.mts +6 -0
  116. package/src/factories/multipart-adapter.factory.d.mts.map +1 -0
  117. package/src/factories/reply.factory.d.mts +6 -0
  118. package/src/factories/reply.factory.d.mts.map +1 -0
  119. package/src/factories/request.factory.d.mts +6 -0
  120. package/src/factories/request.factory.d.mts.map +1 -0
  121. package/src/factories/stream-adapter.factory.d.mts +6 -0
  122. package/src/factories/stream-adapter.factory.d.mts.map +1 -0
  123. package/src/factories/xml-stream-adapter.factory.d.mts +6 -0
  124. package/src/factories/xml-stream-adapter.factory.d.mts.map +1 -0
  125. package/src/index.d.mts +15 -0
  126. package/src/index.d.mts.map +1 -0
  127. package/src/index.mts +1 -0
  128. package/src/interfaces/abstract-execution-context.inteface.d.mts +44 -0
  129. package/src/interfaces/abstract-execution-context.inteface.d.mts.map +1 -0
  130. package/src/interfaces/abstract-execution-context.inteface.mts +35 -0
  131. package/src/interfaces/abstract-http-adapter.interface.d.mts +15 -0
  132. package/src/interfaces/abstract-http-adapter.interface.d.mts.map +1 -0
  133. package/src/interfaces/abstract-http-cors-options.interface.d.mts +58 -0
  134. package/src/interfaces/abstract-http-cors-options.interface.d.mts.map +1 -0
  135. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts +7 -0
  136. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts.map +1 -0
  137. package/src/interfaces/abstract-http-handler-adapter.interface.mts +2 -2
  138. package/src/interfaces/abstract-http-listen-options.interface.d.mts +5 -0
  139. package/src/interfaces/abstract-http-listen-options.interface.d.mts.map +1 -0
  140. package/src/interfaces/can-activate.d.mts +36 -0
  141. package/src/interfaces/can-activate.d.mts.map +1 -0
  142. package/src/interfaces/can-activate.mts +31 -0
  143. package/src/interfaces/http-header.d.mts +10 -0
  144. package/src/interfaces/http-header.d.mts.map +1 -0
  145. package/src/interfaces/index.d.mts +9 -0
  146. package/src/interfaces/index.d.mts.map +1 -0
  147. package/src/interfaces/navios-module.d.mts +29 -0
  148. package/src/interfaces/navios-module.d.mts.map +1 -0
  149. package/src/interfaces/navios-module.mts +25 -0
  150. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +420 -0
  151. package/src/legacy-compat/__type-tests__/tsconfig.json +15 -0
  152. package/src/legacy-compat/context-compat.d.mts +19 -0
  153. package/src/legacy-compat/context-compat.d.mts.map +1 -0
  154. package/src/legacy-compat/context-compat.mts +93 -0
  155. package/src/legacy-compat/decorators/controller.decorator.d.mts +21 -0
  156. package/src/legacy-compat/decorators/controller.decorator.d.mts.map +1 -0
  157. package/src/legacy-compat/decorators/controller.decorator.mts +31 -0
  158. package/src/legacy-compat/decorators/endpoint.decorator.d.mts +33 -0
  159. package/src/legacy-compat/decorators/endpoint.decorator.d.mts.map +1 -0
  160. package/src/legacy-compat/decorators/endpoint.decorator.mts +99 -0
  161. package/src/legacy-compat/decorators/header.decorator.d.mts +24 -0
  162. package/src/legacy-compat/decorators/header.decorator.d.mts.map +1 -0
  163. package/src/legacy-compat/decorators/header.decorator.mts +42 -0
  164. package/src/legacy-compat/decorators/http-code.decorator.d.mts +22 -0
  165. package/src/legacy-compat/decorators/http-code.decorator.d.mts.map +1 -0
  166. package/src/legacy-compat/decorators/http-code.decorator.mts +38 -0
  167. package/src/legacy-compat/decorators/index.d.mts +9 -0
  168. package/src/legacy-compat/decorators/index.d.mts.map +1 -0
  169. package/src/legacy-compat/decorators/index.mts +9 -0
  170. package/src/legacy-compat/decorators/module.decorator.d.mts +22 -0
  171. package/src/legacy-compat/decorators/module.decorator.d.mts.map +1 -0
  172. package/src/legacy-compat/decorators/module.decorator.mts +37 -0
  173. package/src/legacy-compat/decorators/multipart.decorator.d.mts +34 -0
  174. package/src/legacy-compat/decorators/multipart.decorator.d.mts.map +1 -0
  175. package/src/legacy-compat/decorators/multipart.decorator.mts +93 -0
  176. package/src/legacy-compat/decorators/stream.decorator.d.mts +34 -0
  177. package/src/legacy-compat/decorators/stream.decorator.d.mts.map +1 -0
  178. package/src/legacy-compat/decorators/stream.decorator.mts +76 -0
  179. package/src/legacy-compat/decorators/use-guards.decorator.d.mts +29 -0
  180. package/src/legacy-compat/decorators/use-guards.decorator.d.mts.map +1 -0
  181. package/src/legacy-compat/decorators/use-guards.decorator.mts +80 -0
  182. package/src/legacy-compat/index.d.mts +19 -0
  183. package/src/legacy-compat/index.d.mts.map +1 -0
  184. package/src/legacy-compat/index.mts +40 -0
  185. package/src/logger/console-logger.service.d.mts +196 -0
  186. package/src/logger/console-logger.service.d.mts.map +1 -0
  187. package/src/logger/console-logger.service.mts +15 -2
  188. package/src/logger/index.d.mts +7 -0
  189. package/src/logger/index.d.mts.map +1 -0
  190. package/src/logger/log-levels.d.mts +14 -0
  191. package/src/logger/log-levels.d.mts.map +1 -0
  192. package/src/logger/log-levels.mts +9 -0
  193. package/src/logger/logger-service.interface.d.mts +36 -0
  194. package/src/logger/logger-service.interface.d.mts.map +1 -0
  195. package/src/logger/logger.service.d.mts +57 -0
  196. package/src/logger/logger.service.d.mts.map +1 -0
  197. package/src/logger/logger.service.mts +19 -0
  198. package/src/logger/logger.tokens.d.mts +36 -0
  199. package/src/logger/logger.tokens.d.mts.map +1 -0
  200. package/src/logger/logger.tokens.mts +23 -0
  201. package/src/logger/utils/cli-colors.util.d.mts +10 -0
  202. package/src/logger/utils/cli-colors.util.d.mts.map +1 -0
  203. package/src/logger/utils/filter-log-levelts.util.d.mts +6 -0
  204. package/src/logger/utils/filter-log-levelts.util.d.mts.map +1 -0
  205. package/src/logger/utils/index.d.mts +6 -0
  206. package/src/logger/utils/index.d.mts.map +1 -0
  207. package/src/logger/utils/is-log-level-enabled.d.mts +8 -0
  208. package/src/logger/utils/is-log-level-enabled.d.mts.map +1 -0
  209. package/src/logger/utils/is-log-level.util.d.mts +6 -0
  210. package/src/logger/utils/is-log-level.util.d.mts.map +1 -0
  211. package/src/logger/utils/shared.utils.d.mts +14 -0
  212. package/src/logger/utils/shared.utils.d.mts.map +1 -0
  213. package/src/metadata/controller.metadata.d.mts +13 -0
  214. package/src/metadata/controller.metadata.d.mts.map +1 -0
  215. package/src/metadata/handler.metadata.d.mts +18 -0
  216. package/src/metadata/handler.metadata.d.mts.map +1 -0
  217. package/src/metadata/index.d.mts +4 -0
  218. package/src/metadata/index.d.mts.map +1 -0
  219. package/src/metadata/module.metadata.d.mts +13 -0
  220. package/src/metadata/module.metadata.d.mts.map +1 -0
  221. package/src/navios.application.d.mts +210 -0
  222. package/src/navios.application.d.mts.map +1 -0
  223. package/src/navios.application.mts +176 -2
  224. package/src/navios.environment.d.mts +11 -0
  225. package/src/navios.environment.d.mts.map +1 -0
  226. package/src/navios.factory.d.mts +68 -0
  227. package/src/navios.factory.d.mts.map +1 -0
  228. package/src/navios.factory.mts +59 -1
  229. package/src/services/guard-runner.service.d.mts +10 -0
  230. package/src/services/guard-runner.service.d.mts.map +1 -0
  231. package/src/services/guard-runner.service.mts +12 -11
  232. package/src/services/index.d.mts +3 -0
  233. package/src/services/index.d.mts.map +1 -0
  234. package/src/services/module-loader.service.d.mts +17 -0
  235. package/src/services/module-loader.service.d.mts.map +1 -0
  236. package/src/services/module-loader.service.mts +16 -11
  237. package/src/stores/index.d.mts +2 -0
  238. package/src/stores/index.d.mts.map +1 -0
  239. package/src/stores/index.mts +1 -0
  240. package/src/stores/request-id.store.d.mts +37 -0
  241. package/src/stores/request-id.store.d.mts.map +1 -0
  242. package/src/stores/request-id.store.mts +43 -0
  243. package/src/testing/index.mts +2 -0
  244. package/src/testing/testing-module.mts +231 -0
  245. package/src/tokens/endpoint-adapter.token.d.mts +4 -0
  246. package/src/tokens/endpoint-adapter.token.d.mts.map +1 -0
  247. package/src/tokens/execution-context.token.d.mts +5 -0
  248. package/src/tokens/execution-context.token.d.mts.map +1 -0
  249. package/src/tokens/http-adapter.token.d.mts +4 -0
  250. package/src/tokens/http-adapter.token.d.mts.map +1 -0
  251. package/src/tokens/index.d.mts +9 -0
  252. package/src/tokens/index.d.mts.map +1 -0
  253. package/src/tokens/multipart-adapter.token.d.mts +4 -0
  254. package/src/tokens/multipart-adapter.token.d.mts.map +1 -0
  255. package/src/tokens/reply.token.d.mts +3 -0
  256. package/src/tokens/reply.token.d.mts.map +1 -0
  257. package/src/tokens/request.token.d.mts +3 -0
  258. package/src/tokens/request.token.d.mts.map +1 -0
  259. package/src/tokens/stream-adapter.token.d.mts +4 -0
  260. package/src/tokens/stream-adapter.token.d.mts.map +1 -0
  261. package/src/tokens/xml-stream-adapter.token.d.mts +4 -0
  262. package/src/tokens/xml-stream-adapter.token.d.mts.map +1 -0
  263. package/tsconfig.lib.json +1 -1
  264. package/tsconfig.spec.json +3 -0
  265. package/tsdown.config.mts +35 -0
  266. package/vitest.config.mts +6 -0
  267. package/lib/_tsup-dts-rollup.d.mts +0 -1365
  268. package/lib/_tsup-dts-rollup.d.ts +0 -1365
  269. package/lib/index.d.ts +0 -190
  270. package/lib/index.js +0 -1540
  271. package/lib/index.js.map +0 -1
  272. package/lib/index.mjs.map +0 -1
  273. package/tsup.config.mts +0 -13
@@ -0,0 +1,10 @@
1
+ export declare const clc: {
2
+ bold: (text: string) => string;
3
+ green: (text: string) => string;
4
+ yellow: (text: string) => string;
5
+ red: (text: string) => string;
6
+ magentaBright: (text: string) => string;
7
+ cyanBright: (text: string) => string;
8
+ };
9
+ export declare const yellow: (text: string) => string;
10
+ //# sourceMappingURL=cli-colors.util.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-colors.util.d.mts","sourceRoot":"","sources":["cli-colors.util.mts"],"names":[],"mappings":"AAMA,eAAO,MAAM,GAAG;iBAHwC,MAAM;kBAAN,MAAM;mBAAN,MAAM;gBAAN,MAAM;0BAAN,MAAM;uBAAN,MAAM;CAU7D,CAAA;AACD,eAAO,MAAM,MAAM,SAXqC,MAAM,WAa7D,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { LogLevel } from '../log-levels.mjs';
2
+ /**
3
+ * @publicApi
4
+ */
5
+ export declare function filterLogLevels(parseableString?: string): LogLevel[];
6
+ //# sourceMappingURL=filter-log-levelts.util.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-log-levelts.util.d.mts","sourceRoot":"","sources":["filter-log-levelts.util.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAKjD;;GAEG;AACH,wBAAgB,eAAe,CAAC,eAAe,SAAK,GAAG,QAAQ,EAAE,CAoBhE"}
@@ -0,0 +1,6 @@
1
+ export * from './cli-colors.util.mjs';
2
+ export * from './filter-log-levelts.util.mjs';
3
+ export * from './is-log-level.util.mjs';
4
+ export * from './is-log-level-enabled.mjs';
5
+ export * from './shared.utils.mjs';
6
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oBAAoB,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { LogLevel } from '../log-levels.mjs';
2
+ /**
3
+ * Checks if target level is enabled.
4
+ * @param targetLevel target level
5
+ * @param logLevels array of enabled log levels
6
+ */
7
+ export declare function isLogLevelEnabled(targetLevel: LogLevel, logLevels: LogLevel[] | undefined): boolean;
8
+ //# sourceMappingURL=is-log-level-enabled.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-log-level-enabled.d.mts","sourceRoot":"","sources":["is-log-level-enabled.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAWjD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,QAAQ,EACrB,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,GAChC,OAAO,CAaT"}
@@ -0,0 +1,6 @@
1
+ import type { LogLevel } from '../log-levels.mjs';
2
+ /**
3
+ * @publicApi
4
+ */
5
+ export declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
6
+ //# sourceMappingURL=is-log-level.util.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-log-level.util.d.mts","sourceRoot":"","sources":["is-log-level.util.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAIjD;;GAEG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,GAAG,GAAG,aAAa,IAAI,QAAQ,CAExE"}
@@ -0,0 +1,14 @@
1
+ export declare const isUndefined: (obj: any) => obj is undefined;
2
+ export declare const isObject: (fn: any) => fn is object;
3
+ export declare const isPlainObject: (fn: any) => fn is object;
4
+ export declare const addLeadingSlash: (path?: string) => string;
5
+ export declare const normalizePath: (path?: string) => string;
6
+ export declare const stripEndSlash: (path: string) => string;
7
+ export declare const isFunction: (val: any) => val is Function;
8
+ export declare const isString: (val: any) => val is string;
9
+ export declare const isNumber: (val: any) => val is number;
10
+ export declare const isConstructor: (val: any) => boolean;
11
+ export declare const isNil: (val: any) => val is null | undefined;
12
+ export declare const isEmpty: (array: any) => boolean;
13
+ export declare const isSymbol: (val: any) => val is symbol;
14
+ //# sourceMappingURL=shared.utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.utils.d.mts","sourceRoot":"","sources":["shared.utils.mts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,SAClB,CAAA;AAE5B,eAAO,MAAM,QAAQ,GAAI,IAAI,GAAG,KAAG,EAAE,IAAI,MACH,CAAA;AAEtC,eAAO,MAAM,aAAa,GAAI,IAAI,GAAG,KAAG,EAAE,IAAI,MAiB7C,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,MAKxC,CAAA;AAER,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MAKrC,CAAA;AAET,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,WAC6B,CAAA;AAEvE,eAAO,MAAM,UAAU,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,QAClB,CAAA;AAC3B,eAAO,MAAM,QAAQ,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,MAAiC,CAAA;AAC5E,eAAO,MAAM,QAAQ,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,MAAiC,CAAA;AAC5E,eAAO,MAAM,aAAa,GAAI,KAAK,GAAG,KAAG,OAAgC,CAAA;AACzE,eAAO,MAAM,KAAK,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,IAAI,GAAG,SACb,CAAA;AAClC,eAAO,MAAM,OAAO,GAAI,OAAO,GAAG,KAAG,OAAuC,CAAA;AAC5E,eAAO,MAAM,QAAQ,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,MAAiC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import type { ClassType, ClassTypeWithInstance, InjectionToken } from '@navios/di';
2
+ import type { CanActivate } from '../interfaces/index.mjs';
3
+ import type { HandlerMetadata } from './handler.metadata.mjs';
4
+ export declare const ControllerMetadataKey: unique symbol;
5
+ export interface ControllerMetadata {
6
+ endpoints: Set<HandlerMetadata>;
7
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
8
+ customAttributes: Map<string | symbol, any>;
9
+ }
10
+ export declare function getControllerMetadata(target: ClassType, context: ClassDecoratorContext): ControllerMetadata;
11
+ export declare function extractControllerMetadata(target: ClassType): ControllerMetadata;
12
+ export declare function hasControllerMetadata(target: ClassType): boolean;
13
+ //# sourceMappingURL=controller.metadata.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.metadata.d.mts","sourceRoot":"","sources":["controller.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,cAAc,EACf,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAI7D,eAAO,MAAM,qBAAqB,eAAkC,CAAA;AAEpE,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;IAC/B,MAAM,EAAE,GAAG,CACT,qBAAqB,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC,WAAW,EAAE,SAAS,CAAC,CAC5E,CAAA;IACD,gBAAgB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5C;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,qBAAqB,GAC7B,kBAAkB,CAwBpB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,GAChB,kBAAkB,CAWpB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAMhE"}
@@ -0,0 +1,18 @@
1
+ import type { HttpMethod } from '@navios/builder';
2
+ import type { ClassTypeWithInstance, InjectionToken } from '@navios/di';
3
+ import type { AbstractHttpHandlerAdapterInterface, CanActivate, HttpHeader } from '../interfaces/index.mjs';
4
+ export declare const EndpointMetadataKey: unique symbol;
5
+ export interface HandlerMetadata<Config = null> {
6
+ classMethod: string;
7
+ url: string;
8
+ successStatusCode: number;
9
+ adapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface, undefined> | ClassTypeWithInstance<AbstractHttpHandlerAdapterInterface> | null;
10
+ headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
11
+ httpMethod: HttpMethod;
12
+ config: Config;
13
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
14
+ customAttributes: Map<string | symbol, any>;
15
+ }
16
+ export declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<HandlerMetadata<any>>;
17
+ export declare function getEndpointMetadata<Config = any>(target: Function, context: ClassMethodDecoratorContext): HandlerMetadata<Config>;
18
+ //# sourceMappingURL=handler.metadata.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.metadata.d.mts","sourceRoot":"","sources":["handler.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEvE,OAAO,KAAK,EACV,mCAAmC,EACnC,WAAW,EACX,UAAU,EACX,MAAM,yBAAyB,CAAA;AAEhC,eAAO,MAAM,mBAAmB,eAAgC,CAAA;AAEhE,MAAM,WAAW,eAAe,CAAC,MAAM,GAAG,IAAI;IAC5C,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,iBAAiB,EAAE,MAAM,CAAA;IACzB,YAAY,EACR,cAAc,CAAC,mCAAmC,EAAE,SAAS,CAAC,GAC9D,qBAAqB,CAAC,mCAAmC,CAAC,GAC1D,IAAI,CAAA;IACR,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAA;IAC5E,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,GAAG,CACT,qBAAqB,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC,WAAW,EAAE,SAAS,CAAC,CAC5E,CAAA;IACD,gBAAgB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5C;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,2BAA2B,GAAG,qBAAqB,GAC3D,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAa3B;AAED,wBAAgB,mBAAmB,CAAC,MAAM,GAAG,GAAG,EAC9C,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,2BAA2B,GACnC,eAAe,CAAC,MAAM,CAAC,CA+BzB"}
@@ -0,0 +1,4 @@
1
+ export * from './controller.metadata.mjs';
2
+ export * from './handler.metadata.mjs';
3
+ export * from './module.metadata.mjs';
4
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,13 @@
1
+ import type { ClassType, ClassTypeWithInstance, InjectionToken } from '@navios/di';
2
+ import type { CanActivate } from '../index.mjs';
3
+ export declare const ModuleMetadataKey: unique symbol;
4
+ export interface ModuleMetadata {
5
+ controllers: Set<ClassType>;
6
+ imports: Set<ClassType>;
7
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
8
+ customAttributes: Map<string | symbol, any>;
9
+ }
10
+ export declare function getModuleMetadata(target: ClassType, context: ClassDecoratorContext): ModuleMetadata;
11
+ export declare function extractModuleMetadata(target: ClassType): ModuleMetadata;
12
+ export declare function hasModuleMetadata(target: ClassType): boolean;
13
+ //# sourceMappingURL=module.metadata.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.metadata.d.mts","sourceRoot":"","sources":["module.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,cAAc,EACf,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,eAAO,MAAM,iBAAiB,eAAkC,CAAA;AAEhE,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IAC3B,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IACvB,MAAM,EAAE,GAAG,CACT,qBAAqB,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC,WAAW,EAAE,SAAS,CAAC,CAC5E,CAAA;IACD,gBAAgB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5C;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,qBAAqB,GAC7B,cAAc,CAwBhB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,cAAc,CASvE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAG5D"}
@@ -0,0 +1,210 @@
1
+ import type { ClassTypeWithInstance } from '@navios/di';
2
+ import { Container } from '@navios/di';
3
+ import type { AbstractHttpListenOptions, NaviosModule } from './interfaces/index.mjs';
4
+ import type { LoggerService, LogLevel } from './logger/index.mjs';
5
+ import type { NaviosEnvironmentOptions } from './navios.environment.mjs';
6
+ /**
7
+ * Options for configuring the Navios application context.
8
+ * These options control dependency injection and logging behavior.
9
+ */
10
+ export interface NaviosApplicationContextOptions {
11
+ /**
12
+ * Specifies the logger to use. Pass `false` to turn off logging.
13
+ *
14
+ * - `LoggerService` instance: Use a custom logger implementation
15
+ * - `LogLevel[]`: Enable specific log levels (e.g., ['error', 'warn', 'log'])
16
+ * - `false`: Disable logging completely
17
+ */
18
+ logger?: LoggerService | LogLevel[] | false;
19
+ /**
20
+ * Specifies a custom container to use. Useful for testing.
21
+ * If not provided, a new Container will be created.
22
+ */
23
+ container?: Container;
24
+ }
25
+ /**
26
+ * Complete options for creating a Navios application.
27
+ * Extends NaviosApplicationContextOptions with adapter configuration.
28
+ */
29
+ export interface NaviosApplicationOptions extends NaviosApplicationContextOptions {
30
+ /**
31
+ * HTTP adapter environment(s) to use for the application.
32
+ * Can be a single adapter or an array of adapters.
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * adapter: defineFastifyEnvironment()
37
+ * // or
38
+ * adapter: [defineFastifyEnvironment(), defineBunEnvironment()]
39
+ * ```
40
+ */
41
+ adapter: NaviosEnvironmentOptions | NaviosEnvironmentOptions[];
42
+ }
43
+ /**
44
+ * Main application class for Navios.
45
+ *
46
+ * This class represents a Navios application instance and provides methods
47
+ * for initializing, configuring, and managing the HTTP server.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const app = await NaviosFactory.create(AppModule, {
52
+ * adapter: defineFastifyEnvironment(),
53
+ * })
54
+ *
55
+ * app.setGlobalPrefix('/api')
56
+ * app.enableCors({ origin: ['http://localhost:3000'] })
57
+ * await app.init()
58
+ * await app.listen({ port: 3000, host: '0.0.0.0' })
59
+ * ```
60
+ */
61
+ export declare class NaviosApplication {
62
+ private environment;
63
+ private moduleLoader;
64
+ private httpApplication;
65
+ private logger;
66
+ protected container: Container;
67
+ private appModule;
68
+ private options;
69
+ /**
70
+ * Indicates whether the application has been initialized.
71
+ * Set to `true` after `init()` completes successfully.
72
+ */
73
+ isInitialized: boolean;
74
+ /**
75
+ * Sets up the application with the provided module and options.
76
+ * This is called automatically by NaviosFactory.create().
77
+ *
78
+ * @param appModule - The root application module
79
+ * @param options - Application configuration options
80
+ * @internal
81
+ */
82
+ setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): Promise<void>;
83
+ /**
84
+ * Gets the dependency injection container used by this application.
85
+ *
86
+ * @returns The Container instance
87
+ */
88
+ getContainer(): Container;
89
+ /**
90
+ * Initializes the application.
91
+ *
92
+ * This method:
93
+ * - Loads all modules and their dependencies
94
+ * - Sets up the HTTP server if an adapter is configured
95
+ * - Calls onModuleInit hooks on all modules
96
+ * - Marks the application as initialized
97
+ *
98
+ * Must be called before `listen()`.
99
+ *
100
+ * @throws Error if app module is not set
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const app = await NaviosFactory.create(AppModule, {
105
+ * adapter: defineFastifyEnvironment(),
106
+ * })
107
+ * await app.init()
108
+ * await app.listen({ port: 3000 })
109
+ * ```
110
+ */
111
+ init(): Promise<void>;
112
+ private initModules;
113
+ /**
114
+ * Enables CORS (Cross-Origin Resource Sharing) for the application.
115
+ *
116
+ * @param options - CORS configuration options (adapter-specific)
117
+ * @throws Error if HTTP application is not set
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * app.enableCors({
122
+ * origin: ['http://localhost:3000', 'https://example.com'],
123
+ * methods: ['GET', 'POST', 'PUT', 'DELETE'],
124
+ * credentials: true,
125
+ * })
126
+ * ```
127
+ */
128
+ enableCors(options: any): void;
129
+ /**
130
+ * Enables multipart/form-data support for file uploads.
131
+ *
132
+ * @param options - Multipart configuration options (adapter-specific)
133
+ * @throws Error if HTTP application is not set
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * app.enableMultipart({
138
+ * limits: {
139
+ * fileSize: 1024 * 1024 * 10, // 10MB
140
+ * },
141
+ * })
142
+ * ```
143
+ */
144
+ enableMultipart(options: any): void;
145
+ /**
146
+ * Sets a global prefix for all routes.
147
+ *
148
+ * @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
149
+ * @throws Error if HTTP application is not set
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * app.setGlobalPrefix('/api/v1')
154
+ * // All routes will be prefixed with /api/v1
155
+ * ```
156
+ */
157
+ setGlobalPrefix(prefix: string): void;
158
+ /**
159
+ * Gets the underlying HTTP server instance.
160
+ *
161
+ * The type of the returned server depends on the adapter used:
162
+ * - Fastify adapter: Returns FastifyInstance
163
+ * - Bun adapter: Returns Bun.Server
164
+ *
165
+ * @returns The HTTP server instance
166
+ * @throws Error if HTTP application is not set
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * const server = app.getServer()
171
+ * // Use adapter-specific server methods
172
+ * ```
173
+ */
174
+ getServer(): any;
175
+ /**
176
+ * Starts the HTTP server and begins listening for requests.
177
+ *
178
+ * @param options - Listen options (port, host, etc.)
179
+ * @throws Error if HTTP application is not set
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * await app.listen({ port: 3000, host: '0.0.0.0' })
184
+ * ```
185
+ */
186
+ listen(options: AbstractHttpListenOptions): Promise<void>;
187
+ /**
188
+ * Disposes of application resources.
189
+ *
190
+ * Cleans up the HTTP server and module loader.
191
+ * This method is called automatically by `close()`.
192
+ */
193
+ dispose(): Promise<void>;
194
+ /**
195
+ * Closes the application and cleans up all resources.
196
+ *
197
+ * This is an alias for `dispose()`.
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * // Graceful shutdown
202
+ * process.on('SIGTERM', async () => {
203
+ * await app.close()
204
+ * process.exit(0)
205
+ * })
206
+ * ```
207
+ */
208
+ close(): Promise<void>;
209
+ }
210
+ //# sourceMappingURL=navios.application.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navios.application.d.mts","sourceRoot":"","sources":["navios.application.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,OAAO,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAA;AAE1D,OAAO,KAAK,EAEV,yBAAyB,EACzB,YAAY,EACb,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAOxE;;;GAGG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,aAAa,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAA;IAE3C;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,wBACf,SAAQ,+BAA+B;IACvC;;;;;;;;;;OAUG;IACH,OAAO,EAAE,wBAAwB,GAAG,wBAAwB,EAAE,CAAA;CAC/D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBACa,iBAAiB;IAC5B,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,eAAe,CAAiD;IACxE,OAAO,CAAC,MAAM,CAEZ;IACF,SAAS,CAAC,SAAS,YAAoB;IAEvC,OAAO,CAAC,SAAS,CAAmD;IACpE,OAAO,CAAC,OAAO,CAEd;IAED;;;OAGG;IACH,aAAa,UAAQ;IAErB;;;;;;;OAOG;IACG,KAAK,CACT,SAAS,EAAE,qBAAqB,CAAC,YAAY,CAAC,EAC9C,OAAO,GAAE,wBAER;IASH;;;;OAIG;IACH,YAAY;IAIZ;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,IAAI;YAiBI,WAAW;IAKzB;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,OAAO,EAAE,GAAG;IAOvB;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,OAAO,EAAE,GAAG;IAO5B;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM;IAO9B;;;;;;;;;;;;;;;OAeG;IACH,SAAS;IAOT;;;;;;;;;;OAUG;IACG,MAAM,CAAC,OAAO,EAAE,yBAAyB;IAO/C;;;;;OAKG;IACG,OAAO;IASb;;;;;;;;;;;;;OAaG;IACG,KAAK;CAGZ"}
@@ -15,19 +15,65 @@ import { Logger } from './logger/index.mjs'
15
15
  import { NaviosEnvironment } from './navios.environment.mjs'
16
16
  import { ModuleLoaderService } from './services/index.mjs'
17
17
 
18
+ /**
19
+ * Options for configuring the Navios application context.
20
+ * These options control dependency injection and logging behavior.
21
+ */
18
22
  export interface NaviosApplicationContextOptions {
19
23
  /**
20
- * Specifies the logger to use. Pass `false` to turn off logging.
24
+ * Specifies the logger to use. Pass `false` to turn off logging.
25
+ *
26
+ * - `LoggerService` instance: Use a custom logger implementation
27
+ * - `LogLevel[]`: Enable specific log levels (e.g., ['error', 'warn', 'log'])
28
+ * - `false`: Disable logging completely
21
29
  */
22
30
  logger?: LoggerService | LogLevel[] | false
31
+
32
+ /**
33
+ * Specifies a custom container to use. Useful for testing.
34
+ * If not provided, a new Container will be created.
35
+ */
36
+ container?: Container
23
37
  }
24
38
 
39
+ /**
40
+ * Complete options for creating a Navios application.
41
+ * Extends NaviosApplicationContextOptions with adapter configuration.
42
+ */
25
43
  export interface NaviosApplicationOptions
26
44
  extends NaviosApplicationContextOptions {
27
- // Fastify server options will be handled by FastifyApplicationService
45
+ /**
46
+ * HTTP adapter environment(s) to use for the application.
47
+ * Can be a single adapter or an array of adapters.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * adapter: defineFastifyEnvironment()
52
+ * // or
53
+ * adapter: [defineFastifyEnvironment(), defineBunEnvironment()]
54
+ * ```
55
+ */
28
56
  adapter: NaviosEnvironmentOptions | NaviosEnvironmentOptions[]
29
57
  }
30
58
 
59
+ /**
60
+ * Main application class for Navios.
61
+ *
62
+ * This class represents a Navios application instance and provides methods
63
+ * for initializing, configuring, and managing the HTTP server.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const app = await NaviosFactory.create(AppModule, {
68
+ * adapter: defineFastifyEnvironment(),
69
+ * })
70
+ *
71
+ * app.setGlobalPrefix('/api')
72
+ * app.enableCors({ origin: ['http://localhost:3000'] })
73
+ * await app.init()
74
+ * await app.listen({ port: 3000, host: '0.0.0.0' })
75
+ * ```
76
+ */
31
77
  @Injectable()
32
78
  export class NaviosApplication {
33
79
  private environment = inject(NaviosEnvironment)
@@ -43,8 +89,20 @@ export class NaviosApplication {
43
89
  adapter: [],
44
90
  }
45
91
 
92
+ /**
93
+ * Indicates whether the application has been initialized.
94
+ * Set to `true` after `init()` completes successfully.
95
+ */
46
96
  isInitialized = false
47
97
 
98
+ /**
99
+ * Sets up the application with the provided module and options.
100
+ * This is called automatically by NaviosFactory.create().
101
+ *
102
+ * @param appModule - The root application module
103
+ * @param options - Application configuration options
104
+ * @internal
105
+ */
48
106
  async setup(
49
107
  appModule: ClassTypeWithInstance<NaviosModule>,
50
108
  options: NaviosApplicationOptions = {
@@ -58,10 +116,37 @@ export class NaviosApplication {
58
116
  }
59
117
  }
60
118
 
119
+ /**
120
+ * Gets the dependency injection container used by this application.
121
+ *
122
+ * @returns The Container instance
123
+ */
61
124
  getContainer() {
62
125
  return this.container
63
126
  }
64
127
 
128
+ /**
129
+ * Initializes the application.
130
+ *
131
+ * This method:
132
+ * - Loads all modules and their dependencies
133
+ * - Sets up the HTTP server if an adapter is configured
134
+ * - Calls onModuleInit hooks on all modules
135
+ * - Marks the application as initialized
136
+ *
137
+ * Must be called before `listen()`.
138
+ *
139
+ * @throws Error if app module is not set
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const app = await NaviosFactory.create(AppModule, {
144
+ * adapter: defineFastifyEnvironment(),
145
+ * })
146
+ * await app.init()
147
+ * await app.listen({ port: 3000 })
148
+ * ```
149
+ */
65
150
  async init() {
66
151
  if (!this.appModule) {
67
152
  throw new Error('App module is not set. Call setAppModule() first.')
@@ -84,6 +169,21 @@ export class NaviosApplication {
84
169
  await this.httpApplication?.onModulesInit(modules)
85
170
  }
86
171
 
172
+ /**
173
+ * Enables CORS (Cross-Origin Resource Sharing) for the application.
174
+ *
175
+ * @param options - CORS configuration options (adapter-specific)
176
+ * @throws Error if HTTP application is not set
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * app.enableCors({
181
+ * origin: ['http://localhost:3000', 'https://example.com'],
182
+ * methods: ['GET', 'POST', 'PUT', 'DELETE'],
183
+ * credentials: true,
184
+ * })
185
+ * ```
186
+ */
87
187
  enableCors(options: any) {
88
188
  if (!this.httpApplication) {
89
189
  throw new Error('HTTP application is not set')
@@ -91,6 +191,21 @@ export class NaviosApplication {
91
191
  this.httpApplication.enableCors(options)
92
192
  }
93
193
 
194
+ /**
195
+ * Enables multipart/form-data support for file uploads.
196
+ *
197
+ * @param options - Multipart configuration options (adapter-specific)
198
+ * @throws Error if HTTP application is not set
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * app.enableMultipart({
203
+ * limits: {
204
+ * fileSize: 1024 * 1024 * 10, // 10MB
205
+ * },
206
+ * })
207
+ * ```
208
+ */
94
209
  enableMultipart(options: any) {
95
210
  if (!this.httpApplication) {
96
211
  throw new Error('HTTP application is not set')
@@ -98,6 +213,18 @@ export class NaviosApplication {
98
213
  this.httpApplication.enableMultipart(options)
99
214
  }
100
215
 
216
+ /**
217
+ * Sets a global prefix for all routes.
218
+ *
219
+ * @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
220
+ * @throws Error if HTTP application is not set
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * app.setGlobalPrefix('/api/v1')
225
+ * // All routes will be prefixed with /api/v1
226
+ * ```
227
+ */
101
228
  setGlobalPrefix(prefix: string) {
102
229
  if (!this.httpApplication) {
103
230
  throw new Error('HTTP application is not set')
@@ -105,6 +232,22 @@ export class NaviosApplication {
105
232
  this.httpApplication.setGlobalPrefix(prefix)
106
233
  }
107
234
 
235
+ /**
236
+ * Gets the underlying HTTP server instance.
237
+ *
238
+ * The type of the returned server depends on the adapter used:
239
+ * - Fastify adapter: Returns FastifyInstance
240
+ * - Bun adapter: Returns Bun.Server
241
+ *
242
+ * @returns The HTTP server instance
243
+ * @throws Error if HTTP application is not set
244
+ *
245
+ * @example
246
+ * ```typescript
247
+ * const server = app.getServer()
248
+ * // Use adapter-specific server methods
249
+ * ```
250
+ */
108
251
  getServer() {
109
252
  if (!this.httpApplication) {
110
253
  throw new Error('HTTP application is not set')
@@ -112,6 +255,17 @@ export class NaviosApplication {
112
255
  return this.httpApplication.getServer()
113
256
  }
114
257
 
258
+ /**
259
+ * Starts the HTTP server and begins listening for requests.
260
+ *
261
+ * @param options - Listen options (port, host, etc.)
262
+ * @throws Error if HTTP application is not set
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * await app.listen({ port: 3000, host: '0.0.0.0' })
267
+ * ```
268
+ */
115
269
  async listen(options: AbstractHttpListenOptions) {
116
270
  if (!this.httpApplication) {
117
271
  throw new Error('HTTP application is not set')
@@ -119,6 +273,12 @@ export class NaviosApplication {
119
273
  await this.httpApplication.listen(options)
120
274
  }
121
275
 
276
+ /**
277
+ * Disposes of application resources.
278
+ *
279
+ * Cleans up the HTTP server and module loader.
280
+ * This method is called automatically by `close()`.
281
+ */
122
282
  async dispose() {
123
283
  if (this.httpApplication) {
124
284
  await this.httpApplication.dispose()
@@ -128,6 +288,20 @@ export class NaviosApplication {
128
288
  }
129
289
  }
130
290
 
291
+ /**
292
+ * Closes the application and cleans up all resources.
293
+ *
294
+ * This is an alias for `dispose()`.
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * // Graceful shutdown
299
+ * process.on('SIGTERM', async () => {
300
+ * await app.close()
301
+ * process.exit(0)
302
+ * })
303
+ * ```
304
+ */
131
305
  async close() {
132
306
  await this.dispose()
133
307
  }
@@ -0,0 +1,11 @@
1
+ import type { AnyInjectableType, InjectionToken } from '@navios/di';
2
+ export interface NaviosEnvironmentOptions {
3
+ httpTokens?: Map<InjectionToken<any, undefined>, AnyInjectableType>;
4
+ }
5
+ export declare class NaviosEnvironment {
6
+ private httpTokens;
7
+ setupHttpEnvironment(tokens: Map<InjectionToken<any, undefined>, AnyInjectableType>): void;
8
+ getHttpToken(token: InjectionToken<any, undefined>): AnyInjectableType | undefined;
9
+ hasHttpSetup(): boolean;
10
+ }
11
+ //# sourceMappingURL=navios.environment.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navios.environment.d.mts","sourceRoot":"","sources":["navios.environment.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAInE,MAAM,WAAW,wBAAwB;IAEvC,UAAU,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAA;CACpE;AAED,qBACa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAGf;IAEH,oBAAoB,CAClB,MAAM,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAKhE,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC;IAIlD,YAAY;CAGb"}