@venok/http 1.1.0 → 2.0.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 (337) hide show
  1. package/dist/constants.js +33 -0
  2. package/dist/decorators/controller.decorator.js +45 -0
  3. package/dist/decorators/header.decorator.js +28 -0
  4. package/dist/decorators/http-code.decorator.js +22 -0
  5. package/dist/decorators/http-params.decorator.js +63 -0
  6. package/dist/decorators/method.decorator.js +57 -0
  7. package/dist/decorators/redirect.decorator.js +28 -0
  8. package/dist/decorators/version.decorator.js +31 -0
  9. package/dist/enums/method.enum.js +32 -0
  10. package/dist/enums/paramtypes.enum.js +33 -0
  11. package/dist/enums/status.enum.js +71 -0
  12. package/dist/enums/version-type.enum.js +27 -0
  13. package/dist/exceptions/bad-gateway.exception.js +29 -0
  14. package/dist/exceptions/bad-request.exception.js +29 -0
  15. package/dist/exceptions/conflict.exception.js +29 -0
  16. package/dist/exceptions/expectation-failed.exception.js +29 -0
  17. package/dist/exceptions/failed-dependency.exception.js +29 -0
  18. package/dist/exceptions/forbidden.exception.js +29 -0
  19. package/dist/exceptions/gateway-timeout.exception.js +29 -0
  20. package/dist/exceptions/gone.exception.js +29 -0
  21. package/dist/exceptions/http-version-not-supported.exception.js +29 -0
  22. package/dist/exceptions/http.exception.js +94 -0
  23. package/dist/exceptions/im-a-teapot.exception.js +29 -0
  24. package/dist/exceptions/internal-server-error.exception.js +29 -0
  25. package/dist/exceptions/length-required.exception.js +29 -0
  26. package/dist/exceptions/method-not-allowed.exception.js +29 -0
  27. package/dist/exceptions/misdirected.exception.js +29 -0
  28. package/dist/exceptions/not-acceptable.exception.js +29 -0
  29. package/dist/exceptions/not-found.exception.js +29 -0
  30. package/dist/exceptions/not-implemented.exception.js +29 -0
  31. package/dist/exceptions/payload-too-large.exception.js +29 -0
  32. package/dist/exceptions/payment-required.exception.js +29 -0
  33. package/dist/exceptions/precondition-failed.exception.js +29 -0
  34. package/dist/exceptions/precondition-required.exception.js +29 -0
  35. package/dist/exceptions/proxy-authentication-required.exception.js +29 -0
  36. package/dist/exceptions/request-timeout.exception.js +29 -0
  37. package/dist/exceptions/requested-range-not-satisfiable.exception.js +29 -0
  38. package/dist/exceptions/service-unavailable.exception.js +29 -0
  39. package/dist/exceptions/too-many-requests.exception.js +29 -0
  40. package/dist/exceptions/unauthorized.exception.js +29 -0
  41. package/dist/exceptions/unprocessable-entity.exception.js +29 -0
  42. package/dist/exceptions/unsupported-media-type.exception.js +29 -0
  43. package/dist/exceptions/uri-too-long.exception.js +29 -0
  44. package/dist/filters/context.js +28 -0
  45. package/dist/filters/filter.js +56 -0
  46. package/dist/helpers/discovery.helper.js +69 -0
  47. package/dist/helpers/messages.helper.js +41 -0
  48. package/dist/helpers/middleware.helper.js +69 -0
  49. package/dist/helpers/path.helper.js +53 -0
  50. package/dist/helpers/route.helper.js +54 -0
  51. package/dist/http/adapter.js +294 -0
  52. package/dist/http/config.js +67 -0
  53. package/dist/http/configurable-module.js +26 -0
  54. package/dist/http/context.js +117 -0
  55. package/dist/http/explorer.js +133 -0
  56. package/dist/http/module.js +35 -0
  57. package/dist/http/starter-module.js +85 -0
  58. package/dist/index.d.ts +2117 -0
  59. package/dist/index.js +82 -0
  60. package/dist/interfaces/adapter.interface.js +0 -0
  61. package/dist/interfaces/exception.interface.js +0 -0
  62. package/dist/interfaces/index.js +7 -0
  63. package/dist/interfaces/middleware/config-proxy.interface.js +0 -0
  64. package/dist/interfaces/middleware/consumer.interface.js +0 -0
  65. package/dist/interfaces/middleware/index.js +3 -0
  66. package/dist/interfaces/options.interface.js +0 -0
  67. package/dist/interfaces/prefix.interface.js +0 -0
  68. package/dist/interfaces/router/definition.interface.js +0 -0
  69. package/dist/interfaces/router/exclude-route.interface.js +0 -0
  70. package/dist/interfaces/router/index.js +7 -0
  71. package/dist/interfaces/router/info.interface.js +0 -0
  72. package/dist/interfaces/router/path-metadata.interface.js +0 -0
  73. package/dist/interfaces/router/tree.interface.js +0 -0
  74. package/dist/interfaces/router/version.interface.js +21 -0
  75. package/dist/middleware/builder.js +96 -0
  76. package/dist/middleware/module.js +22 -0
  77. package/dist/middleware/routes-mapper.js +107 -0
  78. package/dist/middleware/service.js +48 -0
  79. package/dist/middleware/tree.js +91 -0
  80. package/dist/router/finder.js +64 -0
  81. package/dist/router/module.js +89 -0
  82. package/dist/router/path-factory.js +110 -0
  83. package/dist/symbols.js +33 -0
  84. package/package.json +41 -46
  85. package/adapter/adapter.d.ts +0 -57
  86. package/adapter/adapter.js +0 -58
  87. package/adapter/host.d.ts +0 -27
  88. package/adapter/host.js +0 -33
  89. package/application/application.d.ts +0 -18
  90. package/application/application.js +0 -51
  91. package/application/config.d.ts +0 -16
  92. package/application/config.js +0 -47
  93. package/application/http.module-defenition.d.ts +0 -8
  94. package/application/http.module-defenition.js +0 -6
  95. package/application/http.module.d.ts +0 -3
  96. package/application/http.module.js +0 -21
  97. package/application/http.service.d.ts +0 -11
  98. package/application/http.service.js +0 -43
  99. package/application/starter.d.ts +0 -41
  100. package/application/starter.js +0 -140
  101. package/constants.d.ts +0 -12
  102. package/constants.js +0 -15
  103. package/context/context.d.ts +0 -56
  104. package/context/context.js +0 -102
  105. package/context/response.controller.d.ts +0 -30
  106. package/context/response.controller.js +0 -86
  107. package/decorators/controller.decorator.d.ts +0 -82
  108. package/decorators/controller.decorator.js +0 -53
  109. package/decorators/header.decorator.d.ts +0 -12
  110. package/decorators/header.decorator.js +0 -23
  111. package/decorators/http-code.decorator.d.ts +0 -9
  112. package/decorators/http-code.decorator.js +0 -19
  113. package/decorators/index.d.ts +0 -9
  114. package/decorators/index.js +0 -25
  115. package/decorators/redirect.decorator.d.ts +0 -6
  116. package/decorators/redirect.decorator.js +0 -16
  117. package/decorators/render.decorator.d.ts +0 -10
  118. package/decorators/render.decorator.js +0 -20
  119. package/decorators/request-mapping.decorator.d.ts +0 -78
  120. package/decorators/request-mapping.decorator.js +0 -98
  121. package/decorators/route-params.decorator.d.ts +0 -378
  122. package/decorators/route-params.decorator.js +0 -227
  123. package/decorators/sse.decorator.d.ts +0 -6
  124. package/decorators/sse.decorator.js +0 -20
  125. package/decorators/version.decorator.d.ts +0 -7
  126. package/decorators/version.decorator.js +0 -20
  127. package/enums/http-status.enum.d.ts +0 -53
  128. package/enums/http-status.enum.js +0 -57
  129. package/enums/index.d.ts +0 -4
  130. package/enums/index.js +0 -20
  131. package/enums/request-method.enum.d.ts +0 -11
  132. package/enums/request-method.enum.js +0 -15
  133. package/enums/route-paramtypes.enum.d.ts +0 -14
  134. package/enums/route-paramtypes.enum.js +0 -18
  135. package/enums/version-type.enum.d.ts +0 -9
  136. package/enums/version-type.enum.js +0 -13
  137. package/errors/bad-gateway.exception.d.ts +0 -33
  138. package/errors/bad-gateway.exception.js +0 -41
  139. package/errors/bad-request.exception.d.ts +0 -33
  140. package/errors/bad-request.exception.js +0 -41
  141. package/errors/conflict.exception.d.ts +0 -33
  142. package/errors/conflict.exception.js +0 -41
  143. package/errors/forbidden.exception.d.ts +0 -33
  144. package/errors/forbidden.exception.js +0 -41
  145. package/errors/gateway-timeout.exception.d.ts +0 -33
  146. package/errors/gateway-timeout.exception.js +0 -41
  147. package/errors/gone.exception.d.ts +0 -33
  148. package/errors/gone.exception.js +0 -41
  149. package/errors/http-version-not-supported.exception.d.ts +0 -33
  150. package/errors/http-version-not-supported.exception.js +0 -41
  151. package/errors/http.exception.d.ts +0 -79
  152. package/errors/http.exception.js +0 -123
  153. package/errors/im-a-teapot.exception.d.ts +0 -36
  154. package/errors/im-a-teapot.exception.js +0 -44
  155. package/errors/index.d.ts +0 -11
  156. package/errors/index.js +0 -27
  157. package/errors/internal-server-error.exception.d.ts +0 -33
  158. package/errors/internal-server-error.exception.js +0 -41
  159. package/errors/invalid-middleware-configuration.exception.d.ts +0 -4
  160. package/errors/invalid-middleware-configuration.exception.js +0 -11
  161. package/errors/invalid-middleware.exception.d.ts +0 -4
  162. package/errors/invalid-middleware.exception.js +0 -11
  163. package/errors/not-found.exception.d.ts +0 -33
  164. package/errors/not-found.exception.js +0 -41
  165. package/errors/unknown-request-mapping.exception.d.ts +0 -5
  166. package/errors/unknown-request-mapping.exception.js +0 -11
  167. package/exceptions/messages.d.ts +0 -4
  168. package/exceptions/messages.js +0 -13
  169. package/explorers/path.explorer.d.ts +0 -8
  170. package/explorers/path.explorer.js +0 -38
  171. package/explorers/router.explorer.d.ts +0 -51
  172. package/explorers/router.explorer.js +0 -195
  173. package/factory/context-id.factory.d.ts +0 -41
  174. package/factory/context-id.factory.js +0 -52
  175. package/factory/index.d.ts +0 -4
  176. package/factory/index.js +0 -20
  177. package/factory/method.factory.d.ts +0 -5
  178. package/factory/method.factory.js +0 -30
  179. package/factory/params.factory.d.ts +0 -5
  180. package/factory/params.factory.js +0 -39
  181. package/factory/path.factory.d.ts +0 -13
  182. package/factory/path.factory.js +0 -95
  183. package/filters/context.d.ts +0 -9
  184. package/filters/context.js +0 -15
  185. package/filters/filter.d.ts +0 -22
  186. package/filters/filter.js +0 -78
  187. package/helpers/adapter.helper.d.ts +0 -27
  188. package/helpers/adapter.helper.js +0 -37
  189. package/helpers/exclude-route.helper.d.ts +0 -4
  190. package/helpers/exclude-route.helper.js +0 -18
  191. package/helpers/flatten-routes.helper.d.ts +0 -5
  192. package/helpers/flatten-routes.helper.js +0 -27
  193. package/helpers/index.d.ts +0 -6
  194. package/helpers/index.js +0 -22
  195. package/helpers/messages.helper.d.ts +0 -6
  196. package/helpers/messages.helper.js +0 -25
  197. package/helpers/path.helper.d.ts +0 -3
  198. package/helpers/path.helper.js +0 -13
  199. package/helpers/sse.helper.d.ts +0 -45
  200. package/helpers/sse.helper.js +0 -83
  201. package/index.d.ts +0 -1
  202. package/index.js +0 -3
  203. package/interfaces/http/cors.interface.d.ts +0 -58
  204. package/interfaces/http/cors.interface.js +0 -2
  205. package/interfaces/http/exception.interface.d.ts +0 -6
  206. package/interfaces/http/exception.interface.js +0 -2
  207. package/interfaces/http/exclude-route.interface.d.ts +0 -15
  208. package/interfaces/http/exclude-route.interface.js +0 -2
  209. package/interfaces/http/index.d.ts +0 -10
  210. package/interfaces/http/index.js +0 -26
  211. package/interfaces/http/message-event.interface.d.ts +0 -6
  212. package/interfaces/http/message-event.interface.js +0 -2
  213. package/interfaces/http/module.inteface.d.ts +0 -5
  214. package/interfaces/http/module.inteface.js +0 -2
  215. package/interfaces/http/options.interface.d.ts +0 -127
  216. package/interfaces/http/options.interface.js +0 -2
  217. package/interfaces/http/path-metadata.interface.d.ts +0 -31
  218. package/interfaces/http/path-metadata.interface.js +0 -2
  219. package/interfaces/http/prefix-options.interface.d.ts +0 -7
  220. package/interfaces/http/prefix-options.interface.js +0 -2
  221. package/interfaces/http/raw-request.d.ts +0 -4
  222. package/interfaces/http/raw-request.js +0 -2
  223. package/interfaces/http/routes.interface.d.ts +0 -7
  224. package/interfaces/http/routes.interface.js +0 -2
  225. package/interfaces/http/server.interface.d.ts +0 -54
  226. package/interfaces/http/server.interface.js +0 -2
  227. package/interfaces/index.d.ts +0 -3
  228. package/interfaces/index.js +0 -19
  229. package/interfaces/middleware/config-proxy.interface.d.ts +0 -23
  230. package/interfaces/middleware/config-proxy.interface.js +0 -2
  231. package/interfaces/middleware/configuration.interface.d.ts +0 -12
  232. package/interfaces/middleware/configuration.interface.js +0 -2
  233. package/interfaces/middleware/consumer.interface.d.ts +0 -16
  234. package/interfaces/middleware/consumer.interface.js +0 -2
  235. package/interfaces/middleware/index.d.ts +0 -4
  236. package/interfaces/middleware/index.js +0 -20
  237. package/interfaces/middleware/middleware.interface.d.ts +0 -7
  238. package/interfaces/middleware/middleware.interface.js +0 -2
  239. package/interfaces/router/callback-paramtypes.interface.d.ts +0 -1
  240. package/interfaces/router/callback-paramtypes.interface.js +0 -2
  241. package/interfaces/router/definition.interface.d.ts +0 -10
  242. package/interfaces/router/definition.interface.js +0 -2
  243. package/interfaces/router/index.d.ts +0 -3
  244. package/interfaces/router/index.js +0 -19
  245. package/interfaces/router/version-options.interface.d.ts +0 -92
  246. package/interfaces/router/version-options.interface.js +0 -9
  247. package/middleware/builder.d.ts +0 -15
  248. package/middleware/builder.js +0 -78
  249. package/middleware/container.d.ts +0 -13
  250. package/middleware/container.js +0 -50
  251. package/middleware/extractor.d.ts +0 -15
  252. package/middleware/extractor.js +0 -50
  253. package/middleware/index.d.ts +0 -1
  254. package/middleware/index.js +0 -17
  255. package/middleware/module.d.ts +0 -33
  256. package/middleware/module.js +0 -180
  257. package/middleware/resolver.d.ts +0 -10
  258. package/middleware/resolver.js +0 -27
  259. package/middleware/routes-mapper.d.ts +0 -19
  260. package/middleware/routes-mapper.js +0 -111
  261. package/middleware/utils.d.ts +0 -8
  262. package/middleware/utils.js +0 -86
  263. package/router/module.d.ts +0 -18
  264. package/router/module.js +0 -88
  265. package/router/resolver.d.ts +0 -31
  266. package/router/resolver.js +0 -128
  267. package/storage/http-instance.storage.d.ts +0 -9
  268. package/storage/http-instance.storage.js +0 -19
  269. package/stream/index.d.ts +0 -1
  270. package/stream/index.js +0 -17
  271. package/stream/interfaces/index.d.ts +0 -2
  272. package/stream/interfaces/index.js +0 -18
  273. package/stream/interfaces/streamable-handler-response.interface.d.ts +0 -12
  274. package/stream/interfaces/streamable-handler-response.interface.js +0 -2
  275. package/stream/interfaces/streamable-options.interface.d.ts +0 -10
  276. package/stream/interfaces/streamable-options.interface.js +0 -2
  277. package/stream/streamable-file.d.ts +0 -22
  278. package/stream/streamable-file.js +0 -55
  279. package/test/context/response.controller.spec.d.ts +0 -1
  280. package/test/context/response.controller.spec.js +0 -328
  281. package/test/decorators/controller.decorator.spec.d.ts +0 -1
  282. package/test/decorators/controller.decorator.spec.js +0 -113
  283. package/test/decorators/header.decorator.spec.d.ts +0 -1
  284. package/test/decorators/header.decorator.spec.js +0 -33
  285. package/test/decorators/http-code.decorator.spec.d.ts +0 -1
  286. package/test/decorators/http-code.decorator.spec.js +0 -30
  287. package/test/decorators/redirect.decorator.spec.d.ts +0 -1
  288. package/test/decorators/redirect.decorator.spec.js +0 -36
  289. package/test/decorators/render.decorator.spec.d.ts +0 -1
  290. package/test/decorators/render.decorator.spec.js +0 -30
  291. package/test/decorators/request-mapping.decorator.spec.d.ts +0 -1
  292. package/test/decorators/request-mapping.decorator.spec.js +0 -85
  293. package/test/decorators/route-params.decorator.spec.d.ts +0 -1
  294. package/test/decorators/route-params.decorator.spec.js +0 -493
  295. package/test/decorators/sse.decorator.spec.d.ts +0 -1
  296. package/test/decorators/sse.decorator.spec.js +0 -35
  297. package/test/decorators/version.decorator.spec.d.ts +0 -1
  298. package/test/decorators/version.decorator.spec.js +0 -43
  299. package/test/exceptions/handler.spec.d.ts +0 -1
  300. package/test/exceptions/handler.spec.js +0 -145
  301. package/test/exceptions/proxy.spec.d.ts +0 -1
  302. package/test/exceptions/proxy.spec.js +0 -74
  303. package/test/explorers/path.explorer.spec.d.ts +0 -1
  304. package/test/explorers/path.explorer.spec.js +0 -190
  305. package/test/explorers/router.explorer.spec.d.ts +0 -1
  306. package/test/explorers/router.explorer.spec.js +0 -206
  307. package/test/factory/method.factory.spec.d.ts +0 -1
  308. package/test/factory/method.factory.spec.js +0 -33
  309. package/test/factory/params.factory.spec.d.ts +0 -1
  310. package/test/factory/params.factory.spec.js +0 -104
  311. package/test/factory/path.factory.spec.d.ts +0 -1
  312. package/test/factory/path.factory.spec.js +0 -260
  313. package/test/filters/context.spec.d.ts +0 -1
  314. package/test/filters/context.spec.js +0 -96
  315. package/test/filters/filter.spec.d.ts +0 -1
  316. package/test/filters/filter.spec.js +0 -96
  317. package/test/helpers/flatten-routes.helper.spec.d.ts +0 -1
  318. package/test/helpers/flatten-routes.helper.spec.js +0 -131
  319. package/test/helpers/sse.helper.spec.d.ts +0 -1
  320. package/test/helpers/sse.helper.spec.js +0 -132
  321. package/test/middleware/builder.spec.d.ts +0 -1
  322. package/test/middleware/builder.spec.js +0 -235
  323. package/test/middleware/container.spec.d.ts +0 -1
  324. package/test/middleware/container.spec.js +0 -81
  325. package/test/middleware/module.spec.d.ts +0 -1
  326. package/test/middleware/module.spec.js +0 -206
  327. package/test/middleware/route-info-path-extractor.spec.d.ts +0 -1
  328. package/test/middleware/route-info-path-extractor.spec.js +0 -123
  329. package/test/middleware/routes-mapper.spec.d.ts +0 -1
  330. package/test/middleware/routes-mapper.spec.js +0 -162
  331. package/test/middleware/utils.spec.d.ts +0 -1
  332. package/test/middleware/utils.spec.js +0 -132
  333. package/test/router/module.spec.d.ts +0 -1
  334. package/test/router/module.spec.js +0 -40
  335. package/test/router/resolver.spec.d.ts +0 -1
  336. package/test/router/resolver.spec.js +0 -326
  337. package/tsconfig.tsbuildinfo +0 -1
@@ -1,378 +0,0 @@
1
- import { Type } from "@venok/core";
2
- import { PipeTransform } from "@venok/core/interfaces/features/pipes.interface";
3
- /**
4
- * The `@Response()`/`@Res` parameter decorator options.
5
- */
6
- export interface ResponseDecoratorOptions {
7
- /**
8
- * Determines whether the response will be sent manually within the route handler,
9
- * with the use of native response handling methods exposed by the platform-specific response object,
10
- * or if it should pass through Venok response processing pipeline.
11
- *
12
- * @default false
13
- */
14
- passthrough: boolean;
15
- }
16
- export type ParamData = object | string | number;
17
- export interface RouteParamMetadata {
18
- index: number;
19
- data?: ParamData;
20
- }
21
- export declare function assignMetadata<TParamtype = any, TArgs = any>(args: TArgs, paramtype: TParamtype, index: number, data?: ParamData, ...pipes: (Type<PipeTransform> | PipeTransform)[]): TArgs & {
22
- [x: string]: {
23
- index: number;
24
- data: ParamData | undefined;
25
- pipes: (PipeTransform<any, any> | Type<PipeTransform<any, any>>)[];
26
- };
27
- };
28
- /**
29
- * Route handler parameter decorator. Extracts the `Request`
30
- * object from the underlying platform and populates the decorated
31
- * parameter with the value of `Request`.
32
- *
33
- * Example: `logout(@Request() req)`
34
- *
35
- * @publicApi
36
- */
37
- export declare const Request: () => ParameterDecorator;
38
- /**
39
- * Route handler parameter decorator. Extracts the `Response`
40
- * object from the underlying platform and populates the decorated
41
- * parameter with the value of `Response`.
42
- *
43
- * Example: `logout(@Response() res)`
44
- *
45
- * @publicApi
46
- */
47
- export declare const Response: (options?: ResponseDecoratorOptions) => ParameterDecorator;
48
- /**
49
- * Route handler parameter decorator. Extracts reference to the `Next` function
50
- * from the underlying platform and populates the decorated
51
- * parameter with the value of `Next`.
52
- *
53
- * @publicApi
54
- */
55
- export declare const Next: () => ParameterDecorator;
56
- /**
57
- * Route handler parameter decorator. Extracts the `Ip` property
58
- * from the `req` object and populates the decorated
59
- * parameter with the value of `ip`.
60
-
61
- *
62
- * @publicApi
63
- */
64
- export declare const Ip: () => ParameterDecorator;
65
- /**
66
- * Route handler parameter decorator. Extracts the `Session` object
67
- * from the underlying platform and populates the decorated
68
- * parameter with the value of `Session`.
69
-
70
- *
71
- * @publicApi
72
- */
73
- export declare const Session: () => ParameterDecorator;
74
- /**
75
- * Route handler parameter decorator. Extracts the `file` object
76
- * and populates the decorated parameter with the value of `file`.
77
- * Used in conjunction with multer middleware
78
- *
79
- * For example:
80
- * ```typescript
81
- * uploadFile(@UploadedFile() file) {
82
- * console.log(file);
83
- * }
84
- * ```
85
- *
86
- * @publicApi
87
- */
88
- export declare function UploadedFile(): ParameterDecorator;
89
- /**
90
- * Route handler parameter decorator. Extracts the `file` object
91
- * and populates the decorated parameter with the value of `file`.
92
- * Used in conjunction with
93
- * [multer middleware](https://github.com/expressjs/multer) for Express-based application.
94
- *
95
- * For example:
96
- * ```typescript
97
- * uploadFile(@UploadedFile() file) {
98
- * console.log(file);
99
- * }
100
- * ```
101
- *
102
- * @publicApi
103
- */
104
- export declare function UploadedFile(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
105
- /**
106
- * Route handler parameter decorator. Extracts the `file` object
107
- * and populates the decorated parameter with the value of `file`.
108
- * Used in conjunction with
109
- * [multer middleware](https://github.com/expressjs/multer) for Express-based application.
110
- *
111
- * For example:
112
- * ```typescript
113
- * uploadFile(@UploadedFile() file) {
114
- * console.log(file);
115
- * }
116
- * ```
117
- *
118
- * @publicApi
119
- */
120
- export declare function UploadedFile(fileKey?: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
121
- /**
122
- * Route handler parameter decorator. Extracts the `files` object
123
- * and populates the decorated parameter with the value of `files`.
124
- * Used in conjunction with
125
- * [multer middleware](https://github.com/expressjs/multer) for Express-based application.
126
- *
127
- * For example:
128
- * ```typescript
129
- * uploadFile(@UploadedFiles() files) {
130
- * console.log(files);
131
- * }
132
- * ```
133
- *
134
- * @publicApi
135
- */
136
- export declare function UploadedFiles(): ParameterDecorator;
137
- /**
138
- * Route handler parameter decorator. Extracts the `files` object
139
- * and populates the decorated parameter with the value of `files`.
140
- * Used in conjunction with
141
- * [multer middleware](https://github.com/expressjs/multer) for Express-based application.
142
- *
143
- * For example:
144
- * ```typescript
145
- * uploadFile(@UploadedFiles() files) {
146
- * console.log(files);
147
- * }
148
- * ```
149
- *
150
- * @publicApi
151
- */
152
- export declare function UploadedFiles(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
153
- /**
154
- * Route handler parameter decorator. Extracts the `headers`
155
- * property from the `req` object and populates the decorated
156
- * parameter with the value of `headers`.
157
- *
158
- * For example: `async update(@Headers('Cache-Control') cacheControl: string)`
159
- *
160
- * @param property name of single header property to extract.
161
-
162
- *
163
- * @publicApi
164
- */
165
- export declare const Headers: (property?: string) => ParameterDecorator;
166
- /**
167
- * Route handler parameter decorator. Extracts the `query`
168
- * property from the `req` object and populates the decorated
169
- * parameter with the value of `query`. May also apply pipes to the bound
170
- * query parameter.
171
- *
172
- * For example:
173
- * ```typescript
174
- * async find(@Query('user') user: string)
175
- * ```
176
- *
177
- * @param property name of single property to extract from the `query` object
178
- * @param pipes one or more pipes to apply to the bound query parameter
179
-
180
- *
181
- * @publicApi
182
- */
183
- export declare function Query(): ParameterDecorator;
184
- /**
185
- * Route handler parameter decorator. Extracts the `query`
186
- * property from the `req` object and populates the decorated
187
- * parameter with the value of `query`. May also apply pipes to the bound
188
- * query parameter.
189
- *
190
- * For example:
191
- * ```typescript
192
- * async find(@Query('user') user: string)
193
- * ```
194
- *
195
- * @param property name of single property to extract from the `query` object
196
- * @param pipes one or more pipes to apply to the bound query parameter
197
-
198
- *
199
- * @publicApi
200
- */
201
- export declare function Query(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
202
- /**
203
- * Route handler parameter decorator. Extracts the `query`
204
- * property from the `req` object and populates the decorated
205
- * parameter with the value of `query`. May also apply pipes to the bound
206
- * query parameter.
207
- *
208
- * For example:
209
- * ```typescript
210
- * async find(@Query('user') user: string)
211
- * ```
212
- *
213
- * @param property name of single property to extract from the `query` object
214
- * @param pipes one or more pipes to apply to the bound query parameter
215
-
216
- *
217
- * @publicApi
218
- */
219
- export declare function Query(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
220
- /**
221
- * Route handler parameter decorator. Extracts the entire `body`
222
- * object from the `req` object and populates the decorated
223
- * parameter with the value of `body`.
224
- *
225
- * For example:
226
- * ```typescript
227
- * async create(@Body() createDto: CreateCatDto)
228
- * ```
229
-
230
- *
231
- * @publicApi
232
- */
233
- export declare function Body(): ParameterDecorator;
234
- /**
235
- * Route handler parameter decorator. Extracts the entire `body`
236
- * object from the `req` object and populates the decorated
237
- * parameter with the value of `body`. Also applies the specified
238
- * pipes to that parameter.
239
- *
240
- * For example:
241
- * ```typescript
242
- * async create(@Body(new ValidationPipe()) createDto: CreateCatDto)
243
- * ```
244
- *
245
- * @param pipes one or more pipes - either instances or classes - to apply to
246
- * the bound body parameter.
247
- *
248
- * @publicApi
249
- */
250
- export declare function Body(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
251
- /**
252
- * Route handler parameter decorator. Extracts a single property from
253
- * the `body` object property of the `req` object and populates the decorated
254
- * parameter with the value of that property. Also applies pipes to the bound
255
- * body parameter.
256
- *
257
- * For example:
258
- * ```typescript
259
- * async create(@Body('role', new ValidationPipe()) role: string)
260
- * ```
261
- *
262
- * @param property name of single property to extract from the `body` object
263
- * @param pipes one or more pipes - either instances or classes - to apply to
264
- * the bound body parameter.
265
- *
266
- * @publicApi
267
- */
268
- export declare function Body(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
269
- /**
270
- * Route handler parameter decorator. Extracts the `params`
271
- * property from the `req` object and populates the decorated
272
- * parameter with the value of `params`. May also apply pipes to the bound
273
- * parameter.
274
- *
275
- * For example, extracting all params:
276
- * ```typescript
277
- * findOne(@Param() params: string[])
278
- * ```
279
- *
280
- * For example, extracting a single param:
281
- * ```typescript
282
- * findOne(@Param('id') id: string)
283
- * ```
284
- * @param property name of single property to extract from the `req` object
285
- * @param pipes one or more pipes - either instances or classes - to apply to
286
- * the bound parameter.
287
- *
288
- * @publicApi
289
- */
290
- export declare function Param(): ParameterDecorator;
291
- /**
292
- * Route handler parameter decorator. Extracts the `params`
293
- * property from the `req` object and populates the decorated
294
- * parameter with the value of `params`. May also apply pipes to the bound
295
- * parameter.
296
- *
297
- * For example, extracting all params:
298
- * ```typescript
299
- * findOne(@Param() params: string[])
300
- * ```
301
- *
302
- * For example, extracting a single param:
303
- * ```typescript
304
- * findOne(@Param('id') id: string)
305
- * ```
306
- * @param property name of single property to extract from the `req` object
307
- * @param pipes one or more pipes - either instances or classes - to apply to
308
- * the bound parameter.
309
- *
310
- * @publicApi
311
- */
312
- export declare function Param(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
313
- /**
314
- * Route handler parameter decorator. Extracts the `params`
315
- * property from the `req` object and populates the decorated
316
- * parameter with the value of `params`. May also apply pipes to the bound
317
- * parameter.
318
- *
319
- * For example, extracting all params:
320
- * ```typescript
321
- * findOne(@Param() params: string[])
322
- * ```
323
- *
324
- * For example, extracting a single param:
325
- * ```typescript
326
- * findOne(@Param('id') id: string)
327
- * ```
328
- * @param property name of single property to extract from the `req` object
329
- * @param pipes one or more pipes - either instances or classes - to apply to
330
- * the bound parameter.
331
- *
332
- * @publicApi
333
- */
334
- export declare function Param(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
335
- /**
336
- * Route handler parameter decorator. Extracts the `hosts`
337
- * property from the `req` object and populates the decorated
338
- * parameter with the value of `hosts`. May also apply pipes to the bound
339
- * parameter.
340
- *
341
- * For example, extracting all params:
342
- * ```typescript
343
- * findOne(@HostParam() params: string[])
344
- * ```
345
- *
346
- * For example, extracting a single param:
347
- * ```typescript
348
- * findOne(@HostParam('id') id: string)
349
- * ```
350
- * @param property name of single property to extract from the `req` object
351
-
352
- *
353
- * @publicApi
354
- */
355
- export declare function HostParam(): ParameterDecorator;
356
- /**
357
- * Route handler parameter decorator. Extracts the `hosts`
358
- * property from the `req` object and populates the decorated
359
- * parameter with the value of `hosts`. May also apply pipes to the bound
360
- * parameter.
361
- *
362
- * For example, extracting all params:
363
- * ```typescript
364
- * findOne(@HostParam() params: string[])
365
- * ```
366
- *
367
- * For example, extracting a single param:
368
- * ```typescript
369
- * findOne(@HostParam('id') id: string)
370
- * ```
371
- * @param property name of single property to extract from the `req` object
372
-
373
- *
374
- * @publicApi
375
- */
376
- export declare function HostParam(property: string): ParameterDecorator;
377
- export declare const Req: () => ParameterDecorator;
378
- export declare const Res: (options?: ResponseDecoratorOptions) => ParameterDecorator;
@@ -1,227 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Res = exports.Req = exports.HostParam = exports.Param = exports.Body = exports.Query = exports.Headers = exports.UploadedFiles = exports.UploadedFile = exports.Session = exports.Ip = exports.Next = exports.Response = exports.Request = exports.assignMetadata = void 0;
4
- const constants_1 = require("../../core/constants");
5
- const shared_helper_1 = require("../../core/helpers/shared.helper");
6
- const enums_1 = require("../enums");
7
- const constants_2 = require("@venok/http/constants");
8
- function assignMetadata(args, paramtype, index, data, ...pipes) {
9
- return {
10
- ...args,
11
- [`${paramtype}:${index}`]: {
12
- index,
13
- data,
14
- pipes,
15
- },
16
- };
17
- }
18
- exports.assignMetadata = assignMetadata;
19
- function createRouteParamDecorator(paramtype) {
20
- return (data) => (target, key, index) => {
21
- const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
22
- Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, data), target.constructor, key);
23
- };
24
- }
25
- const createPipesRouteParamDecorator = (paramtype) => (data, ...pipes) => (target, key, index) => {
26
- const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
27
- const hasParamData = (0, shared_helper_1.isNull)(data) || (0, shared_helper_1.isString)(data);
28
- const paramData = hasParamData ? data : undefined;
29
- const paramPipes = hasParamData ? pipes : [data, ...pipes];
30
- Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, paramData, ...paramPipes), target.constructor, key);
31
- };
32
- /**
33
- * Route handler parameter decorator. Extracts the `Request`
34
- * object from the underlying platform and populates the decorated
35
- * parameter with the value of `Request`.
36
- *
37
- * Example: `logout(@Request() req)`
38
- *
39
- * @publicApi
40
- */
41
- exports.Request = createRouteParamDecorator(enums_1.RouteParamtypes.REQUEST);
42
- /**
43
- * Route handler parameter decorator. Extracts the `Response`
44
- * object from the underlying platform and populates the decorated
45
- * parameter with the value of `Response`.
46
- *
47
- * Example: `logout(@Response() res)`
48
- *
49
- * @publicApi
50
- */
51
- const Response = (options) => (target, key, index) => {
52
- if (options?.passthrough) {
53
- Reflect.defineMetadata(constants_2.RESPONSE_PASSTHROUGH_METADATA, options?.passthrough, target.constructor, key);
54
- }
55
- return createRouteParamDecorator(enums_1.RouteParamtypes.RESPONSE)()(target, key, index);
56
- };
57
- exports.Response = Response;
58
- /**
59
- * Route handler parameter decorator. Extracts reference to the `Next` function
60
- * from the underlying platform and populates the decorated
61
- * parameter with the value of `Next`.
62
- *
63
- * @publicApi
64
- */
65
- exports.Next = createRouteParamDecorator(enums_1.RouteParamtypes.NEXT);
66
- /**
67
- * Route handler parameter decorator. Extracts the `Ip` property
68
- * from the `req` object and populates the decorated
69
- * parameter with the value of `ip`.
70
-
71
- *
72
- * @publicApi
73
- */
74
- exports.Ip = createRouteParamDecorator(enums_1.RouteParamtypes.IP);
75
- /**
76
- * Route handler parameter decorator. Extracts the `Session` object
77
- * from the underlying platform and populates the decorated
78
- * parameter with the value of `Session`.
79
-
80
- *
81
- * @publicApi
82
- */
83
- exports.Session = createRouteParamDecorator(enums_1.RouteParamtypes.SESSION);
84
- /**
85
- * Route handler parameter decorator. Extracts the `file` object
86
- * and populates the decorated parameter with the value of `file`.
87
- * Used in conjunction with
88
- * [multer middleware](https://github.com/expressjs/multer) for Express-based application.
89
- *
90
- * For example:
91
- * ```typescript
92
- * uploadFile(@UploadedFile() file) {
93
- * console.log(file);
94
- * }
95
- * ```
96
- *
97
- * @publicApi
98
- */
99
- function UploadedFile(fileKey, ...pipes) {
100
- return createPipesRouteParamDecorator(enums_1.RouteParamtypes.FILE)(fileKey, ...pipes);
101
- }
102
- exports.UploadedFile = UploadedFile;
103
- /**
104
- * Route handler parameter decorator. Extracts the `files` object
105
- * and populates the decorated parameter with the value of `files`.
106
- * Used in conjunction with
107
- * [multer middleware](https://github.com/expressjs/multer) for Express-based application.
108
- *
109
- * For example:
110
- * ```typescript
111
- * uploadFile(@UploadedFiles() files) {
112
- * console.log(files);
113
- * }
114
- * ```
115
- *
116
- * @publicApi
117
- */
118
- function UploadedFiles(...pipes) {
119
- return createPipesRouteParamDecorator(enums_1.RouteParamtypes.FILES)(undefined, ...pipes);
120
- }
121
- exports.UploadedFiles = UploadedFiles;
122
- /**
123
- * Route handler parameter decorator. Extracts the `headers`
124
- * property from the `req` object and populates the decorated
125
- * parameter with the value of `headers`.
126
- *
127
- * For example: `async update(@Headers('Cache-Control') cacheControl: string)`
128
- *
129
- * @param property name of single header property to extract.
130
-
131
- *
132
- * @publicApi
133
- */
134
- exports.Headers = createRouteParamDecorator(enums_1.RouteParamtypes.HEADERS);
135
- /**
136
- * Route handler parameter decorator. Extracts the `query`
137
- * property from the `req` object and populates the decorated
138
- * parameter with the value of `query`. May also apply pipes to the bound
139
- * query parameter.
140
- *
141
- * For example:
142
- * ```typescript
143
- * async find(@Query('user') user: string)
144
- * ```
145
- *
146
- * @param property name of single property to extract from the `query` object
147
- * @param pipes one or more pipes to apply to the bound query parameter
148
-
149
- *
150
- * @publicApi
151
- */
152
- function Query(property, ...pipes) {
153
- return createPipesRouteParamDecorator(enums_1.RouteParamtypes.QUERY)(property, ...pipes);
154
- }
155
- exports.Query = Query;
156
- /**
157
- * Route handler parameter decorator. Extracts the entire `body` object
158
- * property, or optionally a named property of the `body` object, from
159
- * the `req` object and populates the decorated parameter with that value.
160
- * Also applies pipes to the bound body parameter.
161
- *
162
- * For example:
163
- * ```typescript
164
- * async create(@Body('role', new ValidationPipe()) role: string)
165
- * ```
166
- *
167
- * @param property name of single property to extract from the `body` object
168
- * @param pipes one or more pipes - either instances or classes - to apply to
169
- * the bound body parameter.
170
- *
171
- * @publicApi
172
- */
173
- function Body(property, ...pipes) {
174
- return createPipesRouteParamDecorator(enums_1.RouteParamtypes.BODY)(property, ...pipes);
175
- }
176
- exports.Body = Body;
177
- /**
178
- * Route handler parameter decorator. Extracts the `params`
179
- * property from the `req` object and populates the decorated
180
- * parameter with the value of `params`. May also apply pipes to the bound
181
- * parameter.
182
- *
183
- * For example, extracting all params:
184
- * ```typescript
185
- * findOne(@Param() params: string[])
186
- * ```
187
- *
188
- * For example, extracting a single param:
189
- * ```typescript
190
- * findOne(@Param('id') id: string)
191
- * ```
192
- * @param property name of single property to extract from the `req` object
193
- * @param pipes one or more pipes - either instances or classes - to apply to
194
- * the bound parameter.
195
- *
196
- * @publicApi
197
- */
198
- function Param(property, ...pipes) {
199
- return createPipesRouteParamDecorator(enums_1.RouteParamtypes.PARAM)(property, ...pipes);
200
- }
201
- exports.Param = Param;
202
- /**
203
- * Route handler parameter decorator. Extracts the `hosts`
204
- * property from the `req` object and populates the decorated
205
- * parameter with the value of `params`. May also apply pipes to the bound
206
- * parameter.
207
- *
208
- * For example, extracting all params:
209
- * ```typescript
210
- * findOne(@HostParam() params: string[])
211
- * ```
212
- *
213
- * For example, extracting a single param:
214
- * ```typescript
215
- * findOne(@HostParam('id') id: string)
216
- * ```
217
- * @param property name of single property to extract from the `req` object
218
-
219
- *
220
- * @publicApi
221
- */
222
- function HostParam(property) {
223
- return createRouteParamDecorator(enums_1.RouteParamtypes.HOST)(property);
224
- }
225
- exports.HostParam = HostParam;
226
- exports.Req = exports.Request;
227
- exports.Res = exports.Response;
@@ -1,6 +0,0 @@
1
- /**
2
- * Declares this route as a Server-Sent-Events endpoint
3
- *
4
- * @publicApi
5
- */
6
- export declare function Sse(path?: string): MethodDecorator;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Sse = void 0;
4
- const constants_1 = require("@venok/http/constants");
5
- const enums_1 = require("@venok/http/enums");
6
- /**
7
- * Declares this route as a Server-Sent-Events endpoint
8
- *
9
- * @publicApi
10
- */
11
- function Sse(path) {
12
- return (target, key, descriptor) => {
13
- path = path && path.length ? path : "/";
14
- Reflect.defineMetadata(constants_1.PATH_METADATA, path, descriptor.value);
15
- Reflect.defineMetadata(constants_1.METHOD_METADATA, enums_1.RequestMethod.GET, descriptor.value);
16
- Reflect.defineMetadata(constants_1.SSE_METADATA, true, descriptor.value);
17
- return descriptor;
18
- };
19
- }
20
- exports.Sse = Sse;
@@ -1,7 +0,0 @@
1
- import { VersionValue } from "../interfaces";
2
- /**
3
- * Sets the version of the endpoint to the passed version
4
- *
5
- * @publicApi
6
- */
7
- export declare function Version(version: VersionValue): MethodDecorator;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Version = void 0;
4
- const constants_1 = require("@venok/http/constants");
5
- /**
6
- * Sets the version of the endpoint to the passed version
7
- *
8
- * @publicApi
9
- */
10
- function Version(version) {
11
- if (Array.isArray(version)) {
12
- // Drop duplicated versions
13
- version = Array.from(new Set(version));
14
- }
15
- return (target, key, descriptor) => {
16
- Reflect.defineMetadata(constants_1.VERSION_METADATA, version, descriptor.value);
17
- return descriptor;
18
- };
19
- }
20
- exports.Version = Version;