@navios/core 0.5.1 → 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 (277) 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 -188
  13. package/lib/index.mjs +4 -1439
  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 +26 -6
  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/index.mts +1 -0
  116. package/src/factories/multipart-adapter.factory.d.mts +6 -0
  117. package/src/factories/multipart-adapter.factory.d.mts.map +1 -0
  118. package/src/factories/reply.factory.d.mts +6 -0
  119. package/src/factories/reply.factory.d.mts.map +1 -0
  120. package/src/factories/request.factory.d.mts +6 -0
  121. package/src/factories/request.factory.d.mts.map +1 -0
  122. package/src/factories/stream-adapter.factory.d.mts +6 -0
  123. package/src/factories/stream-adapter.factory.d.mts.map +1 -0
  124. package/src/factories/xml-stream-adapter.factory.d.mts +6 -0
  125. package/src/factories/xml-stream-adapter.factory.d.mts.map +1 -0
  126. package/src/factories/xml-stream-adapter.factory.mts +20 -0
  127. package/src/index.d.mts +15 -0
  128. package/src/index.d.mts.map +1 -0
  129. package/src/index.mts +1 -0
  130. package/src/interfaces/abstract-execution-context.inteface.d.mts +44 -0
  131. package/src/interfaces/abstract-execution-context.inteface.d.mts.map +1 -0
  132. package/src/interfaces/abstract-execution-context.inteface.mts +35 -0
  133. package/src/interfaces/abstract-http-adapter.interface.d.mts +15 -0
  134. package/src/interfaces/abstract-http-adapter.interface.d.mts.map +1 -0
  135. package/src/interfaces/abstract-http-cors-options.interface.d.mts +58 -0
  136. package/src/interfaces/abstract-http-cors-options.interface.d.mts.map +1 -0
  137. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts +7 -0
  138. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts.map +1 -0
  139. package/src/interfaces/abstract-http-handler-adapter.interface.mts +2 -2
  140. package/src/interfaces/abstract-http-listen-options.interface.d.mts +5 -0
  141. package/src/interfaces/abstract-http-listen-options.interface.d.mts.map +1 -0
  142. package/src/interfaces/can-activate.d.mts +36 -0
  143. package/src/interfaces/can-activate.d.mts.map +1 -0
  144. package/src/interfaces/can-activate.mts +31 -0
  145. package/src/interfaces/http-header.d.mts +10 -0
  146. package/src/interfaces/http-header.d.mts.map +1 -0
  147. package/src/interfaces/index.d.mts +9 -0
  148. package/src/interfaces/index.d.mts.map +1 -0
  149. package/src/interfaces/navios-module.d.mts +29 -0
  150. package/src/interfaces/navios-module.d.mts.map +1 -0
  151. package/src/interfaces/navios-module.mts +25 -0
  152. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +420 -0
  153. package/src/legacy-compat/__type-tests__/tsconfig.json +15 -0
  154. package/src/legacy-compat/context-compat.d.mts +19 -0
  155. package/src/legacy-compat/context-compat.d.mts.map +1 -0
  156. package/src/legacy-compat/context-compat.mts +93 -0
  157. package/src/legacy-compat/decorators/controller.decorator.d.mts +21 -0
  158. package/src/legacy-compat/decorators/controller.decorator.d.mts.map +1 -0
  159. package/src/legacy-compat/decorators/controller.decorator.mts +31 -0
  160. package/src/legacy-compat/decorators/endpoint.decorator.d.mts +33 -0
  161. package/src/legacy-compat/decorators/endpoint.decorator.d.mts.map +1 -0
  162. package/src/legacy-compat/decorators/endpoint.decorator.mts +99 -0
  163. package/src/legacy-compat/decorators/header.decorator.d.mts +24 -0
  164. package/src/legacy-compat/decorators/header.decorator.d.mts.map +1 -0
  165. package/src/legacy-compat/decorators/header.decorator.mts +42 -0
  166. package/src/legacy-compat/decorators/http-code.decorator.d.mts +22 -0
  167. package/src/legacy-compat/decorators/http-code.decorator.d.mts.map +1 -0
  168. package/src/legacy-compat/decorators/http-code.decorator.mts +38 -0
  169. package/src/legacy-compat/decorators/index.d.mts +9 -0
  170. package/src/legacy-compat/decorators/index.d.mts.map +1 -0
  171. package/src/legacy-compat/decorators/index.mts +9 -0
  172. package/src/legacy-compat/decorators/module.decorator.d.mts +22 -0
  173. package/src/legacy-compat/decorators/module.decorator.d.mts.map +1 -0
  174. package/src/legacy-compat/decorators/module.decorator.mts +37 -0
  175. package/src/legacy-compat/decorators/multipart.decorator.d.mts +34 -0
  176. package/src/legacy-compat/decorators/multipart.decorator.d.mts.map +1 -0
  177. package/src/legacy-compat/decorators/multipart.decorator.mts +93 -0
  178. package/src/legacy-compat/decorators/stream.decorator.d.mts +34 -0
  179. package/src/legacy-compat/decorators/stream.decorator.d.mts.map +1 -0
  180. package/src/legacy-compat/decorators/stream.decorator.mts +76 -0
  181. package/src/legacy-compat/decorators/use-guards.decorator.d.mts +29 -0
  182. package/src/legacy-compat/decorators/use-guards.decorator.d.mts.map +1 -0
  183. package/src/legacy-compat/decorators/use-guards.decorator.mts +80 -0
  184. package/src/legacy-compat/index.d.mts +19 -0
  185. package/src/legacy-compat/index.d.mts.map +1 -0
  186. package/src/legacy-compat/index.mts +40 -0
  187. package/src/logger/console-logger.service.d.mts +196 -0
  188. package/src/logger/console-logger.service.d.mts.map +1 -0
  189. package/src/logger/console-logger.service.mts +15 -2
  190. package/src/logger/index.d.mts +7 -0
  191. package/src/logger/index.d.mts.map +1 -0
  192. package/src/logger/log-levels.d.mts +14 -0
  193. package/src/logger/log-levels.d.mts.map +1 -0
  194. package/src/logger/log-levels.mts +9 -0
  195. package/src/logger/logger-service.interface.d.mts +36 -0
  196. package/src/logger/logger-service.interface.d.mts.map +1 -0
  197. package/src/logger/logger.service.d.mts +57 -0
  198. package/src/logger/logger.service.d.mts.map +1 -0
  199. package/src/logger/logger.service.mts +19 -0
  200. package/src/logger/logger.tokens.d.mts +36 -0
  201. package/src/logger/logger.tokens.d.mts.map +1 -0
  202. package/src/logger/logger.tokens.mts +23 -0
  203. package/src/logger/utils/cli-colors.util.d.mts +10 -0
  204. package/src/logger/utils/cli-colors.util.d.mts.map +1 -0
  205. package/src/logger/utils/filter-log-levelts.util.d.mts +6 -0
  206. package/src/logger/utils/filter-log-levelts.util.d.mts.map +1 -0
  207. package/src/logger/utils/index.d.mts +6 -0
  208. package/src/logger/utils/index.d.mts.map +1 -0
  209. package/src/logger/utils/is-log-level-enabled.d.mts +8 -0
  210. package/src/logger/utils/is-log-level-enabled.d.mts.map +1 -0
  211. package/src/logger/utils/is-log-level.util.d.mts +6 -0
  212. package/src/logger/utils/is-log-level.util.d.mts.map +1 -0
  213. package/src/logger/utils/shared.utils.d.mts +14 -0
  214. package/src/logger/utils/shared.utils.d.mts.map +1 -0
  215. package/src/metadata/controller.metadata.d.mts +13 -0
  216. package/src/metadata/controller.metadata.d.mts.map +1 -0
  217. package/src/metadata/handler.metadata.d.mts +18 -0
  218. package/src/metadata/handler.metadata.d.mts.map +1 -0
  219. package/src/metadata/index.d.mts +4 -0
  220. package/src/metadata/index.d.mts.map +1 -0
  221. package/src/metadata/module.metadata.d.mts +13 -0
  222. package/src/metadata/module.metadata.d.mts.map +1 -0
  223. package/src/navios.application.d.mts +210 -0
  224. package/src/navios.application.d.mts.map +1 -0
  225. package/src/navios.application.mts +176 -2
  226. package/src/navios.environment.d.mts +11 -0
  227. package/src/navios.environment.d.mts.map +1 -0
  228. package/src/navios.factory.d.mts +68 -0
  229. package/src/navios.factory.d.mts.map +1 -0
  230. package/src/navios.factory.mts +59 -1
  231. package/src/services/guard-runner.service.d.mts +10 -0
  232. package/src/services/guard-runner.service.d.mts.map +1 -0
  233. package/src/services/guard-runner.service.mts +12 -11
  234. package/src/services/index.d.mts +3 -0
  235. package/src/services/index.d.mts.map +1 -0
  236. package/src/services/module-loader.service.d.mts +17 -0
  237. package/src/services/module-loader.service.d.mts.map +1 -0
  238. package/src/services/module-loader.service.mts +16 -11
  239. package/src/stores/index.d.mts +2 -0
  240. package/src/stores/index.d.mts.map +1 -0
  241. package/src/stores/index.mts +1 -0
  242. package/src/stores/request-id.store.d.mts +37 -0
  243. package/src/stores/request-id.store.d.mts.map +1 -0
  244. package/src/stores/request-id.store.mts +43 -0
  245. package/src/testing/index.mts +2 -0
  246. package/src/testing/testing-module.mts +231 -0
  247. package/src/tokens/endpoint-adapter.token.d.mts +4 -0
  248. package/src/tokens/endpoint-adapter.token.d.mts.map +1 -0
  249. package/src/tokens/execution-context.token.d.mts +5 -0
  250. package/src/tokens/execution-context.token.d.mts.map +1 -0
  251. package/src/tokens/http-adapter.token.d.mts +4 -0
  252. package/src/tokens/http-adapter.token.d.mts.map +1 -0
  253. package/src/tokens/index.d.mts +9 -0
  254. package/src/tokens/index.d.mts.map +1 -0
  255. package/src/tokens/index.mts +1 -0
  256. package/src/tokens/multipart-adapter.token.d.mts +4 -0
  257. package/src/tokens/multipart-adapter.token.d.mts.map +1 -0
  258. package/src/tokens/reply.token.d.mts +3 -0
  259. package/src/tokens/reply.token.d.mts.map +1 -0
  260. package/src/tokens/request.token.d.mts +3 -0
  261. package/src/tokens/request.token.d.mts.map +1 -0
  262. package/src/tokens/stream-adapter.token.d.mts +4 -0
  263. package/src/tokens/stream-adapter.token.d.mts.map +1 -0
  264. package/src/tokens/xml-stream-adapter.token.d.mts +4 -0
  265. package/src/tokens/xml-stream-adapter.token.d.mts.map +1 -0
  266. package/src/tokens/xml-stream-adapter.token.mts +8 -0
  267. package/tsconfig.lib.json +1 -1
  268. package/tsconfig.spec.json +3 -0
  269. package/tsdown.config.mts +35 -0
  270. package/vitest.config.mts +6 -0
  271. package/lib/_tsup-dts-rollup.d.mts +0 -1352
  272. package/lib/_tsup-dts-rollup.d.ts +0 -1352
  273. package/lib/index.d.ts +0 -188
  274. package/lib/index.js +0 -1519
  275. package/lib/index.js.map +0 -1
  276. package/lib/index.mjs.map +0 -1
  277. package/tsup.config.mts +0 -13
@@ -11,6 +11,30 @@ import { ZodDiscriminatedUnion } from 'zod/v4'
11
11
  import { getEndpointMetadata } from '../metadata/index.mjs'
12
12
  import { EndpointAdapterToken } from '../tokens/index.mjs'
13
13
 
14
+ /**
15
+ * Extracts the typed parameters for an endpoint handler function.
16
+ *
17
+ * This utility type extracts URL parameters, query parameters, and request body
18
+ * from an endpoint declaration and flattens them into a single object.
19
+ *
20
+ * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const getUserEndpoint = api.declareEndpoint({
25
+ * method: 'get',
26
+ * url: '/users/$userId',
27
+ * querySchema: z.object({ include: z.string().optional() }),
28
+ * responseSchema: z.object({ id: z.string(), name: z.string() }),
29
+ * })
30
+ *
31
+ * @Endpoint(getUserEndpoint)
32
+ * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
33
+ * // request.urlParams.userId is typed as string
34
+ * // request.query.include is typed as string | undefined
35
+ * }
36
+ * ```
37
+ */
14
38
  export type EndpointParams<
15
39
  EndpointDeclaration extends {
16
40
  config: BaseEndpointConfig<any, any, any, any, any>
@@ -39,6 +63,28 @@ export type EndpointParams<
39
63
  >
40
64
  : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>
41
65
 
66
+ /**
67
+ * Extracts the typed return value for an endpoint handler function.
68
+ *
69
+ * This utility type extracts the response schema from an endpoint declaration
70
+ * and returns the appropriate Promise type.
71
+ *
72
+ * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const getUserEndpoint = api.declareEndpoint({
77
+ * method: 'get',
78
+ * url: '/users/$userId',
79
+ * responseSchema: z.object({ id: z.string(), name: z.string() }),
80
+ * })
81
+ *
82
+ * @Endpoint(getUserEndpoint)
83
+ * async getUser(request: EndpointParams<typeof getUserEndpoint>): EndpointResult<typeof getUserEndpoint> {
84
+ * return { id: '1', name: 'John' } // Type-checked against responseSchema
85
+ * }
86
+ * ```
87
+ */
42
88
  export type EndpointResult<
43
89
  EndpointDeclaration extends {
44
90
  config: BaseEndpointConfig<any, any, any, any, any>
@@ -50,6 +96,36 @@ export type EndpointResult<
50
96
  ? Promise<z.input<Options[number]>>
51
97
  : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>
52
98
 
99
+ /**
100
+ * Decorator that marks a method as an HTTP endpoint.
101
+ *
102
+ * The endpoint must be defined using @navios/builder's `declareEndpoint` method.
103
+ * This ensures type safety and consistency between client and server.
104
+ *
105
+ * @param endpoint - The endpoint declaration from @navios/builder
106
+ * @returns A method decorator
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * import { builder } from '@navios/builder'
111
+ *
112
+ * const api = builder()
113
+ * const getUserEndpoint = api.declareEndpoint({
114
+ * method: 'get',
115
+ * url: '/users/$userId',
116
+ * responseSchema: z.object({ id: z.string(), name: z.string() }),
117
+ * })
118
+ *
119
+ * @Controller()
120
+ * export class UserController {
121
+ * @Endpoint(getUserEndpoint)
122
+ * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
123
+ * const { userId } = request.urlParams
124
+ * return { id: userId, name: 'John' }
125
+ * }
126
+ * }
127
+ * ```
128
+ */
53
129
  export function Endpoint<
54
130
  Method extends HttpMethod = HttpMethod,
55
131
  Url extends string = string,
@@ -0,0 +1,22 @@
1
+ import type { HttpHeader } from '../interfaces/index.mjs';
2
+ /**
3
+ * Decorator that sets a custom HTTP response header for an endpoint.
4
+ *
5
+ * @param name - The header name (e.g., 'Content-Type', 'Cache-Control')
6
+ * @param value - The header value (string, number, or array of strings)
7
+ * @returns A method decorator
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * @Controller()
12
+ * export class UserController {
13
+ * @Endpoint(getUserEndpoint)
14
+ * @Header('Cache-Control', 'max-age=3600')
15
+ * async getUser() {
16
+ * return { id: '1', name: 'John' }
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function Header(name: HttpHeader, value: string | number | string[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
22
+ //# sourceMappingURL=header.decorator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header.decorator.d.mts","sourceRoot":"","sources":["header.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAIzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,IAChE,CAAC,SAAS,QAAQ,EACxB,QAAQ,CAAC,EACT,SAAS,2BAA2B,OAWvC"}
@@ -2,6 +2,25 @@ import type { HttpHeader } from '../interfaces/index.mjs'
2
2
 
3
3
  import { getEndpointMetadata } from '../metadata/index.mjs'
4
4
 
5
+ /**
6
+ * Decorator that sets a custom HTTP response header for an endpoint.
7
+ *
8
+ * @param name - The header name (e.g., 'Content-Type', 'Cache-Control')
9
+ * @param value - The header value (string, number, or array of strings)
10
+ * @returns A method decorator
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * @Controller()
15
+ * export class UserController {
16
+ * @Endpoint(getUserEndpoint)
17
+ * @Header('Cache-Control', 'max-age=3600')
18
+ * async getUser() {
19
+ * return { id: '1', name: 'John' }
20
+ * }
21
+ * }
22
+ * ```
23
+ */
5
24
  export function Header(name: HttpHeader, value: string | number | string[]) {
6
25
  return <T extends Function>(
7
26
  target: T,
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Decorator that sets a custom HTTP status code for successful responses.
3
+ *
4
+ * By default, endpoints return 200 OK. Use this decorator to return a different status code.
5
+ *
6
+ * @param code - The HTTP status code to return (e.g., 201, 204, 202)
7
+ * @returns A method decorator
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * @Controller()
12
+ * export class UserController {
13
+ * @Endpoint(createUserEndpoint)
14
+ * @HttpCode(201)
15
+ * async createUser() {
16
+ * return { id: '1', name: 'John' }
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function HttpCode(code: number): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
22
+ //# sourceMappingURL=http-code.decorator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-code.decorator.d.mts","sourceRoot":"","sources":["http-code.decorator.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,IAC3B,CAAC,SAAS,QAAQ,EACxB,QAAQ,CAAC,EACT,SAAS,2BAA2B,OAYvC"}
@@ -1,5 +1,25 @@
1
1
  import { getEndpointMetadata } from '../metadata/index.mjs'
2
2
 
3
+ /**
4
+ * Decorator that sets a custom HTTP status code for successful responses.
5
+ *
6
+ * By default, endpoints return 200 OK. Use this decorator to return a different status code.
7
+ *
8
+ * @param code - The HTTP status code to return (e.g., 201, 204, 202)
9
+ * @returns A method decorator
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * @Controller()
14
+ * export class UserController {
15
+ * @Endpoint(createUserEndpoint)
16
+ * @HttpCode(201)
17
+ * async createUser() {
18
+ * return { id: '1', name: 'John' }
19
+ * }
20
+ * }
21
+ * ```
22
+ */
3
23
  export function HttpCode(code: number) {
4
24
  return <T extends Function>(
5
25
  target: T,
@@ -0,0 +1,9 @@
1
+ export * from './controller.decorator.mjs';
2
+ export * from './endpoint.decorator.mjs';
3
+ export * from './header.decorator.mjs';
4
+ export * from './http-code.decorator.mjs';
5
+ export * from './module.decorator.mjs';
6
+ export * from './multipart.decorator.mjs';
7
+ export * from './stream.decorator.mjs';
8
+ export * from './use-guards.decorator.mjs';
9
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,4BAA4B,CAAA"}
@@ -0,0 +1,42 @@
1
+ import type { ClassType } from '@navios/di';
2
+ /**
3
+ * Options for configuring a Navios module.
4
+ */
5
+ export interface ModuleOptions {
6
+ /**
7
+ * Controllers to register in this module.
8
+ * Controllers handle HTTP requests and define endpoints.
9
+ */
10
+ controllers?: ClassType[] | Set<ClassType>;
11
+ /**
12
+ * Other modules to import into this module.
13
+ * Imported modules' controllers and services become available.
14
+ */
15
+ imports?: ClassType[] | Set<ClassType>;
16
+ /**
17
+ * Guards to apply to all controllers in this module.
18
+ * Guards are executed in reverse order (last guard first).
19
+ */
20
+ guards?: ClassType[] | Set<ClassType>;
21
+ }
22
+ /**
23
+ * Decorator that marks a class as a Navios module.
24
+ *
25
+ * Modules are the basic building blocks of a Navios application.
26
+ * They organize controllers, services, and other modules into logical units.
27
+ *
28
+ * @param options - Module configuration options
29
+ * @returns A class decorator
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * @Module({
34
+ * controllers: [UserController, AuthController],
35
+ * imports: [DatabaseModule],
36
+ * guards: [AuthGuard],
37
+ * })
38
+ * export class AppModule {}
39
+ * ```
40
+ */
41
+ export declare function Module({ controllers, imports, guards }?: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
42
+ //# sourceMappingURL=module.decorator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.decorator.d.mts","sourceRoot":"","sources":["module.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAM3C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;IAC1C;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;IACtC;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;CACtC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CACpB,EAAE,WAAgB,EAAE,OAAY,EAAE,MAAW,EAAE,GAAE,aAIhD,IAEO,QAAQ,SAAS,EAAE,SAAS,qBAAqB,eAsB1D"}
@@ -4,12 +4,46 @@ import { Injectable, InjectableScope, InjectionToken } from '@navios/di'
4
4
 
5
5
  import { getModuleMetadata } from '../metadata/index.mjs'
6
6
 
7
+ /**
8
+ * Options for configuring a Navios module.
9
+ */
7
10
  export interface ModuleOptions {
11
+ /**
12
+ * Controllers to register in this module.
13
+ * Controllers handle HTTP requests and define endpoints.
14
+ */
8
15
  controllers?: ClassType[] | Set<ClassType>
16
+ /**
17
+ * Other modules to import into this module.
18
+ * Imported modules' controllers and services become available.
19
+ */
9
20
  imports?: ClassType[] | Set<ClassType>
21
+ /**
22
+ * Guards to apply to all controllers in this module.
23
+ * Guards are executed in reverse order (last guard first).
24
+ */
10
25
  guards?: ClassType[] | Set<ClassType>
11
26
  }
12
27
 
28
+ /**
29
+ * Decorator that marks a class as a Navios module.
30
+ *
31
+ * Modules are the basic building blocks of a Navios application.
32
+ * They organize controllers, services, and other modules into logical units.
33
+ *
34
+ * @param options - Module configuration options
35
+ * @returns A class decorator
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * @Module({
40
+ * controllers: [UserController, AuthController],
41
+ * imports: [DatabaseModule],
42
+ * guards: [AuthGuard],
43
+ * })
44
+ * export class AppModule {}
45
+ * ```
46
+ */
13
47
  export function Module(
14
48
  { controllers = [], imports = [], guards = [] }: ModuleOptions = {
15
49
  controllers: [],
@@ -0,0 +1,54 @@
1
+ import type { BaseEndpointConfig, EndpointFunctionArgs, HttpMethod, Util_FlatObject } from '@navios/builder';
2
+ import type { z, ZodObject, ZodType } from 'zod/v4';
3
+ import { ZodDiscriminatedUnion } from 'zod/v4';
4
+ /**
5
+ * Extracts the typed parameters for a multipart endpoint handler function.
6
+ *
7
+ * Similar to `EndpointParams`, but specifically for multipart/form-data endpoints.
8
+ *
9
+ * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
10
+ */
11
+ export type MultipartParams<EndpointDeclaration extends {
12
+ config: BaseEndpointConfig<any, any, any, any, any>;
13
+ }, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
14
+ /**
15
+ * Extracts the typed return value for a multipart endpoint handler function.
16
+ *
17
+ * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
18
+ */
19
+ export type MultipartResult<EndpointDeclaration extends {
20
+ config: BaseEndpointConfig<any, any, any, any, any>;
21
+ }> = EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<infer Options> ? Promise<z.input<Options[number]>> : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>;
22
+ /**
23
+ * Decorator that marks a method as a multipart/form-data endpoint.
24
+ *
25
+ * Use this decorator for endpoints that handle file uploads or form data.
26
+ * The endpoint must be defined using @navios/builder's `declareMultipart` method.
27
+ *
28
+ * @param endpoint - The multipart endpoint declaration from @navios/builder
29
+ * @returns A method decorator
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const uploadFileEndpoint = api.declareMultipart({
34
+ * method: 'post',
35
+ * url: '/upload',
36
+ * requestSchema: z.object({ file: z.instanceof(File) }),
37
+ * responseSchema: z.object({ url: z.string() }),
38
+ * })
39
+ *
40
+ * @Controller()
41
+ * export class FileController {
42
+ * @Multipart(uploadFileEndpoint)
43
+ * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>) {
44
+ * const { file } = request.data
45
+ * // Handle file upload
46
+ * return { url: 'https://example.com/file.jpg' }
47
+ * }
48
+ * }
49
+ * ```
50
+ */
51
+ export declare function Multipart<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
52
+ config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
53
+ }): (target: (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => Promise<z.input<ResponseSchema>>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => Promise<z.input<ResponseSchema>>;
54
+ //# sourceMappingURL=multipart.decorator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multipart.decorator.d.mts","sourceRoot":"","sources":["multipart.decorator.mts"],"names":[],"mappings":"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"}
@@ -11,6 +11,13 @@ import { ZodDiscriminatedUnion } from 'zod/v4'
11
11
  import { getEndpointMetadata } from '../metadata/index.mjs'
12
12
  import { MultipartAdapterToken } from '../tokens/index.mjs'
13
13
 
14
+ /**
15
+ * Extracts the typed parameters for a multipart endpoint handler function.
16
+ *
17
+ * Similar to `EndpointParams`, but specifically for multipart/form-data endpoints.
18
+ *
19
+ * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
20
+ */
14
21
  export type MultipartParams<
15
22
  EndpointDeclaration extends {
16
23
  config: BaseEndpointConfig<any, any, any, any, any>
@@ -39,6 +46,11 @@ export type MultipartParams<
39
46
  >
40
47
  : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>
41
48
 
49
+ /**
50
+ * Extracts the typed return value for a multipart endpoint handler function.
51
+ *
52
+ * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
53
+ */
42
54
  export type MultipartResult<
43
55
  EndpointDeclaration extends {
44
56
  config: BaseEndpointConfig<any, any, any, any, any>
@@ -50,6 +62,35 @@ export type MultipartResult<
50
62
  ? Promise<z.input<Options[number]>>
51
63
  : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>
52
64
 
65
+ /**
66
+ * Decorator that marks a method as a multipart/form-data endpoint.
67
+ *
68
+ * Use this decorator for endpoints that handle file uploads or form data.
69
+ * The endpoint must be defined using @navios/builder's `declareMultipart` method.
70
+ *
71
+ * @param endpoint - The multipart endpoint declaration from @navios/builder
72
+ * @returns A method decorator
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const uploadFileEndpoint = api.declareMultipart({
77
+ * method: 'post',
78
+ * url: '/upload',
79
+ * requestSchema: z.object({ file: z.instanceof(File) }),
80
+ * responseSchema: z.object({ url: z.string() }),
81
+ * })
82
+ *
83
+ * @Controller()
84
+ * export class FileController {
85
+ * @Multipart(uploadFileEndpoint)
86
+ * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>) {
87
+ * const { file } = request.data
88
+ * // Handle file upload
89
+ * return { url: 'https://example.com/file.jpg' }
90
+ * }
91
+ * }
92
+ * ```
93
+ */
53
94
  export function Multipart<
54
95
  Method extends HttpMethod = HttpMethod,
55
96
  Url extends string = string,
@@ -0,0 +1,42 @@
1
+ import type { BaseStreamConfig, EndpointFunctionArgs, HttpMethod, Util_FlatObject } from '@navios/builder';
2
+ import type { ZodObject, ZodType } from 'zod/v4';
3
+ /**
4
+ * Extracts the typed parameters for a stream endpoint handler function.
5
+ *
6
+ * Similar to `EndpointParams`, but specifically for streaming endpoints.
7
+ *
8
+ * @typeParam EndpointDeclaration - The stream endpoint declaration from @navios/builder
9
+ */
10
+ export type StreamParams<EndpointDeclaration extends {
11
+ config: BaseStreamConfig<any, any, any, any>;
12
+ }, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
13
+ /**
14
+ * Decorator that marks a method as a streaming endpoint.
15
+ *
16
+ * Use this decorator for endpoints that stream data (e.g., file downloads, SSE).
17
+ * The endpoint must be defined using @navios/builder's `declareStream` method.
18
+ *
19
+ * @param endpoint - The stream endpoint declaration from @navios/builder
20
+ * @returns A method decorator
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const downloadFileEndpoint = api.declareStream({
25
+ * method: 'get',
26
+ * url: '/files/$fileId',
27
+ * })
28
+ *
29
+ * @Controller()
30
+ * export class FileController {
31
+ * @Stream(downloadFileEndpoint)
32
+ * async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {
33
+ * const { fileId } = request.urlParams
34
+ * // Stream file data to reply
35
+ * }
36
+ * }
37
+ * ```
38
+ */
39
+ export declare function Stream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType>(endpoint: {
40
+ config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>;
41
+ }): (target: (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>, reply: any) => Promise<void>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>, reply: any) => Promise<void>;
42
+ //# sourceMappingURL=stream.decorator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.decorator.d.mts","sourceRoot":"","sources":["stream.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,eAAe,EAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAKhD;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,CACtB,mBAAmB,SAAS;IAC1B,MAAM,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;CAC7C,EACD,GAAG,SAAS,MAAM,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,EACzD,WAAW,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,IACxD,WAAW,SAAS,SAAS,GAC7B,mBAAmB,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,SAAS,OAAO,GAC5D,eAAe,CACb,oBAAoB,CAClB,GAAG,EACH,WAAW,EACX,mBAAmB,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,EAC9C,IAAI,CACL,CACF,GACD,eAAe,CAAC,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,GAC1E,mBAAmB,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,SAAS,OAAO,GAC5D,eAAe,CACb,oBAAoB,CAClB,GAAG,EACH,SAAS,EACT,mBAAmB,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,EAC9C,IAAI,CACL,CACF,GACD,eAAe,CAAC,oBAAoB,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAA;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,MAAM,CACpB,MAAM,SAAS,UAAU,GAAG,UAAU,EACtC,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,WAAW,GAAG,SAAS,EACvB,aAAa,GAAG,OAAO,EACvB,QAAQ,EAAE;IACV,MAAM,EAAE,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,CAAA;CAClE,IAEG,QAAQ,CACN,MAAM,EAAE,WAAW,SAAS,SAAS,GACjC,aAAa,SAAS,OAAO,GAC3B,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,GACrD,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,GACnD,aAAa,SAAS,OAAO,GAC3B,oBAAoB,CAAC,GAAG,EAAE,SAAS,EAAE,aAAa,CAAC,GACnD,oBAAoB,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,EACrD,KAAK,EAAE,GAAG,KACP,OAAO,CAAC,IAAI,CAAC,EAClB,SAAS,2BAA2B,cAT1B,WAAW,SAAS,SAAS,GACjC,aAAa,SAAS,OAAO,GAC3B,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,GACrD,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,GACnD,aAAa,SAAS,OAAO,GAC3B,oBAAoB,CAAC,GAAG,EAAE,SAAS,EAAE,aAAa,CAAC,GACnD,oBAAoB,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,SAC9C,GAAG,KACP,OAAO,CAAC,IAAI,CAAC,CAiCrB"}
@@ -9,6 +9,13 @@ import type { ZodObject, ZodType } from 'zod/v4'
9
9
  import { getEndpointMetadata } from '../metadata/index.mjs'
10
10
  import { StreamAdapterToken } from '../tokens/index.mjs'
11
11
 
12
+ /**
13
+ * Extracts the typed parameters for a stream endpoint handler function.
14
+ *
15
+ * Similar to `EndpointParams`, but specifically for streaming endpoints.
16
+ *
17
+ * @typeParam EndpointDeclaration - The stream endpoint declaration from @navios/builder
18
+ */
12
19
  export type StreamParams<
13
20
  EndpointDeclaration extends {
14
21
  config: BaseStreamConfig<any, any, any, any>
@@ -37,6 +44,32 @@ export type StreamParams<
37
44
  >
38
45
  : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>
39
46
 
47
+ /**
48
+ * Decorator that marks a method as a streaming endpoint.
49
+ *
50
+ * Use this decorator for endpoints that stream data (e.g., file downloads, SSE).
51
+ * The endpoint must be defined using @navios/builder's `declareStream` method.
52
+ *
53
+ * @param endpoint - The stream endpoint declaration from @navios/builder
54
+ * @returns A method decorator
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const downloadFileEndpoint = api.declareStream({
59
+ * method: 'get',
60
+ * url: '/files/$fileId',
61
+ * })
62
+ *
63
+ * @Controller()
64
+ * export class FileController {
65
+ * @Stream(downloadFileEndpoint)
66
+ * async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {
67
+ * const { fileId } = request.urlParams
68
+ * // Stream file data to reply
69
+ * }
70
+ * }
71
+ * ```
72
+ */
40
73
  export function Stream<
41
74
  Method extends HttpMethod = HttpMethod,
42
75
  Url extends string = string,
@@ -0,0 +1,33 @@
1
+ import type { ClassTypeWithInstance, InjectionToken } from '@navios/di';
2
+ import type { CanActivate } from '../interfaces/index.mjs';
3
+ /**
4
+ * Decorator that applies guards to a controller or endpoint.
5
+ *
6
+ * Guards are used for authentication, authorization, and request validation.
7
+ * They implement the `CanActivate` interface and are executed before the endpoint handler.
8
+ * Guards can be applied at the module, controller, or endpoint level.
9
+ *
10
+ * @param guards - Guard classes or injection tokens to apply
11
+ * @returns A class or method decorator
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Apply to a controller
16
+ * @Controller()
17
+ * @UseGuards(AuthGuard, RoleGuard)
18
+ * export class UserController {
19
+ * @Endpoint(getUserEndpoint)
20
+ * async getUser() { }
21
+ * }
22
+ *
23
+ * // Apply to a specific endpoint
24
+ * @Controller()
25
+ * export class UserController {
26
+ * @Endpoint(getUserEndpoint)
27
+ * @UseGuards(AuthGuard)
28
+ * async getUser() { }
29
+ * }
30
+ * ```
31
+ */
32
+ export declare function UseGuards(...guards: (ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>)[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext | ClassDecoratorContext) => T;
33
+ //# sourceMappingURL=use-guards.decorator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-guards.decorator.d.mts","sourceRoot":"","sources":["use-guards.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,qBAAqB,EACrB,cAAc,EACf,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAO1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,SAAS,CACvB,GAAG,MAAM,EAAE,CACP,qBAAqB,CAAC,WAAW,CAAC,GAClC,cAAc,CAAC,WAAW,EAAE,SAAS,CAAC,CACzC,EAAE,IAEc,CAAC,SAAS,QAAQ,EACjC,QAAQ,CAAC,EACT,SAAS,2BAA2B,GAAG,qBAAqB,KAC3D,CAAC,CAqBL"}
@@ -11,6 +11,35 @@ import {
11
11
  getEndpointMetadata,
12
12
  } from '../metadata/index.mjs'
13
13
 
14
+ /**
15
+ * Decorator that applies guards to a controller or endpoint.
16
+ *
17
+ * Guards are used for authentication, authorization, and request validation.
18
+ * They implement the `CanActivate` interface and are executed before the endpoint handler.
19
+ * Guards can be applied at the module, controller, or endpoint level.
20
+ *
21
+ * @param guards - Guard classes or injection tokens to apply
22
+ * @returns A class or method decorator
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Apply to a controller
27
+ * @Controller()
28
+ * @UseGuards(AuthGuard, RoleGuard)
29
+ * export class UserController {
30
+ * @Endpoint(getUserEndpoint)
31
+ * async getUser() { }
32
+ * }
33
+ *
34
+ * // Apply to a specific endpoint
35
+ * @Controller()
36
+ * export class UserController {
37
+ * @Endpoint(getUserEndpoint)
38
+ * @UseGuards(AuthGuard)
39
+ * async getUser() { }
40
+ * }
41
+ * ```
42
+ */
14
43
  export function UseGuards(
15
44
  ...guards: (
16
45
  | ClassTypeWithInstance<CanActivate>
@@ -0,0 +1,26 @@
1
+ import { HttpException } from './http.exception.mjs';
2
+ /**
3
+ * Exception that represents a 400 Bad Request HTTP error.
4
+ *
5
+ * Use this exception when the client's request is malformed or invalid.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * @Endpoint(createUserEndpoint)
10
+ * async createUser(request: EndpointParams<typeof createUserEndpoint>) {
11
+ * if (!request.data.email) {
12
+ * throw new BadRequestException('Email is required')
13
+ * }
14
+ * // ...
15
+ * }
16
+ * ```
17
+ */
18
+ export declare class BadRequestException extends HttpException {
19
+ /**
20
+ * Creates a new BadRequestException.
21
+ *
22
+ * @param message - Error message or response object
23
+ */
24
+ constructor(message: string | object);
25
+ }
26
+ //# sourceMappingURL=bad-request.exception.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bad-request.exception.d.mts","sourceRoot":"","sources":["bad-request.exception.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;IACpD;;;;OAIG;gBACS,OAAO,EAAE,MAAM,GAAG,MAAM;CAGrC"}