@venok/http 1.0.1-canary.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 (254) hide show
  1. package/adapter/adapter.d.ts +57 -0
  2. package/adapter/adapter.js +58 -0
  3. package/adapter/host.d.ts +27 -0
  4. package/adapter/host.js +33 -0
  5. package/application/application.d.ts +18 -0
  6. package/application/application.js +51 -0
  7. package/application/config.d.ts +16 -0
  8. package/application/config.js +47 -0
  9. package/application/http.module-defenition.d.ts +8 -0
  10. package/application/http.module-defenition.js +6 -0
  11. package/application/http.module.d.ts +3 -0
  12. package/application/http.module.js +21 -0
  13. package/application/http.service.d.ts +11 -0
  14. package/application/http.service.js +43 -0
  15. package/application/starter.d.ts +41 -0
  16. package/application/starter.js +140 -0
  17. package/constants.d.ts +12 -0
  18. package/constants.js +15 -0
  19. package/context/context.d.ts +56 -0
  20. package/context/context.js +102 -0
  21. package/context/response.controller.d.ts +30 -0
  22. package/context/response.controller.js +86 -0
  23. package/decorators/controller.decorator.d.ts +82 -0
  24. package/decorators/controller.decorator.js +53 -0
  25. package/decorators/header.decorator.d.ts +12 -0
  26. package/decorators/header.decorator.js +23 -0
  27. package/decorators/http-code.decorator.d.ts +9 -0
  28. package/decorators/http-code.decorator.js +19 -0
  29. package/decorators/index.d.ts +9 -0
  30. package/decorators/index.js +25 -0
  31. package/decorators/redirect.decorator.d.ts +6 -0
  32. package/decorators/redirect.decorator.js +16 -0
  33. package/decorators/render.decorator.d.ts +10 -0
  34. package/decorators/render.decorator.js +20 -0
  35. package/decorators/request-mapping.decorator.d.ts +78 -0
  36. package/decorators/request-mapping.decorator.js +98 -0
  37. package/decorators/route-params.decorator.d.ts +378 -0
  38. package/decorators/route-params.decorator.js +227 -0
  39. package/decorators/sse.decorator.d.ts +6 -0
  40. package/decorators/sse.decorator.js +20 -0
  41. package/decorators/version.decorator.d.ts +7 -0
  42. package/decorators/version.decorator.js +20 -0
  43. package/enums/http-status.enum.d.ts +53 -0
  44. package/enums/http-status.enum.js +57 -0
  45. package/enums/index.d.ts +4 -0
  46. package/enums/index.js +20 -0
  47. package/enums/request-method.enum.d.ts +11 -0
  48. package/enums/request-method.enum.js +15 -0
  49. package/enums/route-paramtypes.enum.d.ts +14 -0
  50. package/enums/route-paramtypes.enum.js +18 -0
  51. package/enums/version-type.enum.d.ts +9 -0
  52. package/enums/version-type.enum.js +13 -0
  53. package/errors/bad-gateway.exception.d.ts +33 -0
  54. package/errors/bad-gateway.exception.js +41 -0
  55. package/errors/bad-request.exception.d.ts +33 -0
  56. package/errors/bad-request.exception.js +41 -0
  57. package/errors/conflict.exception.d.ts +33 -0
  58. package/errors/conflict.exception.js +41 -0
  59. package/errors/forbidden.exception.d.ts +33 -0
  60. package/errors/forbidden.exception.js +41 -0
  61. package/errors/gateway-timeout.exception.d.ts +33 -0
  62. package/errors/gateway-timeout.exception.js +41 -0
  63. package/errors/gone.exception.d.ts +33 -0
  64. package/errors/gone.exception.js +41 -0
  65. package/errors/http-version-not-supported.exception.d.ts +33 -0
  66. package/errors/http-version-not-supported.exception.js +41 -0
  67. package/errors/http.exception.d.ts +79 -0
  68. package/errors/http.exception.js +123 -0
  69. package/errors/im-a-teapot.exception.d.ts +36 -0
  70. package/errors/im-a-teapot.exception.js +44 -0
  71. package/errors/index.d.ts +11 -0
  72. package/errors/index.js +27 -0
  73. package/errors/internal-server-error.exception.d.ts +33 -0
  74. package/errors/internal-server-error.exception.js +41 -0
  75. package/errors/invalid-middleware-configuration.exception.d.ts +4 -0
  76. package/errors/invalid-middleware-configuration.exception.js +11 -0
  77. package/errors/invalid-middleware.exception.d.ts +4 -0
  78. package/errors/invalid-middleware.exception.js +11 -0
  79. package/errors/not-found.exception.d.ts +33 -0
  80. package/errors/not-found.exception.js +41 -0
  81. package/errors/unknown-request-mapping.exception.d.ts +5 -0
  82. package/errors/unknown-request-mapping.exception.js +11 -0
  83. package/exceptions/messages.d.ts +4 -0
  84. package/exceptions/messages.js +13 -0
  85. package/explorers/path.explorer.d.ts +8 -0
  86. package/explorers/path.explorer.js +38 -0
  87. package/explorers/router.explorer.d.ts +51 -0
  88. package/explorers/router.explorer.js +195 -0
  89. package/factory/context-id.factory.d.ts +41 -0
  90. package/factory/context-id.factory.js +52 -0
  91. package/factory/index.d.ts +4 -0
  92. package/factory/index.js +20 -0
  93. package/factory/method.factory.d.ts +5 -0
  94. package/factory/method.factory.js +30 -0
  95. package/factory/params.factory.d.ts +5 -0
  96. package/factory/params.factory.js +39 -0
  97. package/factory/path.factory.d.ts +13 -0
  98. package/factory/path.factory.js +95 -0
  99. package/filters/context.d.ts +9 -0
  100. package/filters/context.js +15 -0
  101. package/filters/filter.d.ts +22 -0
  102. package/filters/filter.js +78 -0
  103. package/helpers/adapter.helper.d.ts +27 -0
  104. package/helpers/adapter.helper.js +37 -0
  105. package/helpers/exclude-route.helper.d.ts +4 -0
  106. package/helpers/exclude-route.helper.js +18 -0
  107. package/helpers/flatten-routes.helper.d.ts +5 -0
  108. package/helpers/flatten-routes.helper.js +27 -0
  109. package/helpers/index.d.ts +6 -0
  110. package/helpers/index.js +22 -0
  111. package/helpers/messages.helper.d.ts +6 -0
  112. package/helpers/messages.helper.js +25 -0
  113. package/helpers/path.helper.d.ts +3 -0
  114. package/helpers/path.helper.js +13 -0
  115. package/helpers/sse.helper.d.ts +45 -0
  116. package/helpers/sse.helper.js +83 -0
  117. package/index.d.ts +1 -0
  118. package/index.js +3 -0
  119. package/interfaces/http/cors.interface.d.ts +58 -0
  120. package/interfaces/http/cors.interface.js +2 -0
  121. package/interfaces/http/exception.interface.d.ts +6 -0
  122. package/interfaces/http/exception.interface.js +2 -0
  123. package/interfaces/http/exclude-route.interface.d.ts +15 -0
  124. package/interfaces/http/exclude-route.interface.js +2 -0
  125. package/interfaces/http/index.d.ts +10 -0
  126. package/interfaces/http/index.js +26 -0
  127. package/interfaces/http/message-event.interface.d.ts +6 -0
  128. package/interfaces/http/message-event.interface.js +2 -0
  129. package/interfaces/http/module.inteface.d.ts +5 -0
  130. package/interfaces/http/module.inteface.js +2 -0
  131. package/interfaces/http/options.interface.d.ts +127 -0
  132. package/interfaces/http/options.interface.js +2 -0
  133. package/interfaces/http/path-metadata.interface.d.ts +31 -0
  134. package/interfaces/http/path-metadata.interface.js +2 -0
  135. package/interfaces/http/prefix-options.interface.d.ts +7 -0
  136. package/interfaces/http/prefix-options.interface.js +2 -0
  137. package/interfaces/http/raw-request.d.ts +4 -0
  138. package/interfaces/http/raw-request.js +2 -0
  139. package/interfaces/http/routes.interface.d.ts +7 -0
  140. package/interfaces/http/routes.interface.js +2 -0
  141. package/interfaces/http/server.interface.d.ts +54 -0
  142. package/interfaces/http/server.interface.js +2 -0
  143. package/interfaces/index.d.ts +3 -0
  144. package/interfaces/index.js +19 -0
  145. package/interfaces/middleware/config-proxy.interface.d.ts +23 -0
  146. package/interfaces/middleware/config-proxy.interface.js +2 -0
  147. package/interfaces/middleware/configuration.interface.d.ts +12 -0
  148. package/interfaces/middleware/configuration.interface.js +2 -0
  149. package/interfaces/middleware/consumer.interface.d.ts +16 -0
  150. package/interfaces/middleware/consumer.interface.js +2 -0
  151. package/interfaces/middleware/index.d.ts +4 -0
  152. package/interfaces/middleware/index.js +20 -0
  153. package/interfaces/middleware/middleware.interface.d.ts +7 -0
  154. package/interfaces/middleware/middleware.interface.js +2 -0
  155. package/interfaces/router/callback-paramtypes.interface.d.ts +1 -0
  156. package/interfaces/router/callback-paramtypes.interface.js +2 -0
  157. package/interfaces/router/definition.interface.d.ts +10 -0
  158. package/interfaces/router/definition.interface.js +2 -0
  159. package/interfaces/router/index.d.ts +3 -0
  160. package/interfaces/router/index.js +19 -0
  161. package/interfaces/router/version-options.interface.d.ts +92 -0
  162. package/interfaces/router/version-options.interface.js +9 -0
  163. package/middleware/builder.d.ts +15 -0
  164. package/middleware/builder.js +78 -0
  165. package/middleware/container.d.ts +13 -0
  166. package/middleware/container.js +50 -0
  167. package/middleware/extractor.d.ts +15 -0
  168. package/middleware/extractor.js +50 -0
  169. package/middleware/index.d.ts +1 -0
  170. package/middleware/index.js +17 -0
  171. package/middleware/module.d.ts +33 -0
  172. package/middleware/module.js +180 -0
  173. package/middleware/resolver.d.ts +10 -0
  174. package/middleware/resolver.js +27 -0
  175. package/middleware/routes-mapper.d.ts +19 -0
  176. package/middleware/routes-mapper.js +111 -0
  177. package/middleware/utils.d.ts +8 -0
  178. package/middleware/utils.js +86 -0
  179. package/package.json +41 -0
  180. package/router/module.d.ts +18 -0
  181. package/router/module.js +88 -0
  182. package/router/resolver.d.ts +31 -0
  183. package/router/resolver.js +128 -0
  184. package/storage/http-instance.storage.d.ts +9 -0
  185. package/storage/http-instance.storage.js +19 -0
  186. package/stream/index.d.ts +1 -0
  187. package/stream/index.js +17 -0
  188. package/stream/interfaces/index.d.ts +2 -0
  189. package/stream/interfaces/index.js +18 -0
  190. package/stream/interfaces/streamable-handler-response.interface.d.ts +12 -0
  191. package/stream/interfaces/streamable-handler-response.interface.js +2 -0
  192. package/stream/interfaces/streamable-options.interface.d.ts +10 -0
  193. package/stream/interfaces/streamable-options.interface.js +2 -0
  194. package/stream/streamable-file.d.ts +22 -0
  195. package/stream/streamable-file.js +55 -0
  196. package/test/context/response.controller.spec.d.ts +1 -0
  197. package/test/context/response.controller.spec.js +328 -0
  198. package/test/decorators/controller.decorator.spec.d.ts +1 -0
  199. package/test/decorators/controller.decorator.spec.js +113 -0
  200. package/test/decorators/header.decorator.spec.d.ts +1 -0
  201. package/test/decorators/header.decorator.spec.js +33 -0
  202. package/test/decorators/http-code.decorator.spec.d.ts +1 -0
  203. package/test/decorators/http-code.decorator.spec.js +30 -0
  204. package/test/decorators/redirect.decorator.spec.d.ts +1 -0
  205. package/test/decorators/redirect.decorator.spec.js +36 -0
  206. package/test/decorators/render.decorator.spec.d.ts +1 -0
  207. package/test/decorators/render.decorator.spec.js +30 -0
  208. package/test/decorators/request-mapping.decorator.spec.d.ts +1 -0
  209. package/test/decorators/request-mapping.decorator.spec.js +85 -0
  210. package/test/decorators/route-params.decorator.spec.d.ts +1 -0
  211. package/test/decorators/route-params.decorator.spec.js +493 -0
  212. package/test/decorators/sse.decorator.spec.d.ts +1 -0
  213. package/test/decorators/sse.decorator.spec.js +35 -0
  214. package/test/decorators/version.decorator.spec.d.ts +1 -0
  215. package/test/decorators/version.decorator.spec.js +43 -0
  216. package/test/exceptions/handler.spec.d.ts +1 -0
  217. package/test/exceptions/handler.spec.js +145 -0
  218. package/test/exceptions/proxy.spec.d.ts +1 -0
  219. package/test/exceptions/proxy.spec.js +74 -0
  220. package/test/explorers/path.explorer.spec.d.ts +1 -0
  221. package/test/explorers/path.explorer.spec.js +190 -0
  222. package/test/explorers/router.explorer.spec.d.ts +1 -0
  223. package/test/explorers/router.explorer.spec.js +206 -0
  224. package/test/factory/method.factory.spec.d.ts +1 -0
  225. package/test/factory/method.factory.spec.js +33 -0
  226. package/test/factory/params.factory.spec.d.ts +1 -0
  227. package/test/factory/params.factory.spec.js +104 -0
  228. package/test/factory/path.factory.spec.d.ts +1 -0
  229. package/test/factory/path.factory.spec.js +260 -0
  230. package/test/filters/context.spec.d.ts +1 -0
  231. package/test/filters/context.spec.js +96 -0
  232. package/test/filters/filter.spec.d.ts +1 -0
  233. package/test/filters/filter.spec.js +96 -0
  234. package/test/helpers/flatten-routes.helper.spec.d.ts +1 -0
  235. package/test/helpers/flatten-routes.helper.spec.js +131 -0
  236. package/test/helpers/sse.helper.spec.d.ts +1 -0
  237. package/test/helpers/sse.helper.spec.js +132 -0
  238. package/test/middleware/builder.spec.d.ts +1 -0
  239. package/test/middleware/builder.spec.js +235 -0
  240. package/test/middleware/container.spec.d.ts +1 -0
  241. package/test/middleware/container.spec.js +81 -0
  242. package/test/middleware/module.spec.d.ts +1 -0
  243. package/test/middleware/module.spec.js +206 -0
  244. package/test/middleware/route-info-path-extractor.spec.d.ts +1 -0
  245. package/test/middleware/route-info-path-extractor.spec.js +123 -0
  246. package/test/middleware/routes-mapper.spec.d.ts +1 -0
  247. package/test/middleware/routes-mapper.spec.js +162 -0
  248. package/test/middleware/utils.spec.d.ts +1 -0
  249. package/test/middleware/utils.spec.js +132 -0
  250. package/test/router/module.spec.d.ts +1 -0
  251. package/test/router/module.spec.js +40 -0
  252. package/test/router/resolver.spec.d.ts +1 -0
  253. package/test/router/resolver.spec.js +326 -0
  254. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Search = exports.All = exports.Head = exports.Options = exports.Patch = exports.Put = exports.Delete = exports.Get = exports.Post = exports.RequestMapping = void 0;
4
+ const constants_1 = require("@venok/http/constants");
5
+ const enums_1 = require("@venok/http/enums");
6
+ const defaultMetadata = {
7
+ [constants_1.PATH_METADATA]: "/",
8
+ [constants_1.METHOD_METADATA]: enums_1.RequestMethod.GET,
9
+ };
10
+ const RequestMapping = (metadata = defaultMetadata) => {
11
+ const pathMetadata = metadata[constants_1.PATH_METADATA];
12
+ const path = pathMetadata && pathMetadata.length ? pathMetadata : "/";
13
+ const requestMethod = metadata[constants_1.METHOD_METADATA] || enums_1.RequestMethod.GET;
14
+ return (target, key, descriptor) => {
15
+ Reflect.defineMetadata(constants_1.PATH_METADATA, path, descriptor.value);
16
+ Reflect.defineMetadata(constants_1.METHOD_METADATA, requestMethod, descriptor.value);
17
+ return descriptor;
18
+ };
19
+ };
20
+ exports.RequestMapping = RequestMapping;
21
+ const createMappingDecorator = (method) => (path) => {
22
+ return (0, exports.RequestMapping)({
23
+ [constants_1.PATH_METADATA]: path,
24
+ [constants_1.METHOD_METADATA]: method,
25
+ });
26
+ };
27
+ /**
28
+ * Route handler (method) Decorator. Routes HTTP POST requests to the specified path.
29
+ *
30
+ * @see [Routing](https://docs.nestjs.com/controllers#routing)
31
+ *
32
+ * @publicApi
33
+ */
34
+ exports.Post = createMappingDecorator(enums_1.RequestMethod.POST);
35
+ /**
36
+ * Route handler (method) Decorator. Routes HTTP GET requests to the specified path.
37
+ *
38
+ * @see [Routing](https://docs.nestjs.com/controllers#routing)
39
+ *
40
+ * @publicApi
41
+ */
42
+ exports.Get = createMappingDecorator(enums_1.RequestMethod.GET);
43
+ /**
44
+ * Route handler (method) Decorator. Routes HTTP DELETE requests to the specified path.
45
+ *
46
+ * @see [Routing](https://docs.nestjs.com/controllers#routing)
47
+ *
48
+ * @publicApi
49
+ */
50
+ exports.Delete = createMappingDecorator(enums_1.RequestMethod.DELETE);
51
+ /**
52
+ * Route handler (method) Decorator. Routes HTTP PUT requests to the specified path.
53
+ *
54
+ * @see [Routing](https://docs.nestjs.com/controllers#routing)
55
+ *
56
+ * @publicApi
57
+ */
58
+ exports.Put = createMappingDecorator(enums_1.RequestMethod.PUT);
59
+ /**
60
+ * Route handler (method) Decorator. Routes HTTP PATCH requests to the specified path.
61
+ *
62
+ * @see [Routing](https://docs.nestjs.com/controllers#routing)
63
+ *
64
+ * @publicApi
65
+ */
66
+ exports.Patch = createMappingDecorator(enums_1.RequestMethod.PATCH);
67
+ /**
68
+ * Route handler (method) Decorator. Routes HTTP OPTIONS requests to the specified path.
69
+ *
70
+ * @see [Routing](https://docs.nestjs.com/controllers#routing)
71
+ *
72
+ * @publicApi
73
+ */
74
+ exports.Options = createMappingDecorator(enums_1.RequestMethod.OPTIONS);
75
+ /**
76
+ * Route handler (method) Decorator. Routes HTTP HEAD requests to the specified path.
77
+ *
78
+ * @see [Routing](https://docs.nestjs.com/controllers#routing)
79
+ *
80
+ * @publicApi
81
+ */
82
+ exports.Head = createMappingDecorator(enums_1.RequestMethod.HEAD);
83
+ /**
84
+ * Route handler (method) Decorator. Routes all HTTP requests to the specified path.
85
+ *
86
+ * @see [Routing](https://docs.nestjs.com/controllers#routing)
87
+ *
88
+ * @publicApi
89
+ */
90
+ exports.All = createMappingDecorator(enums_1.RequestMethod.ALL);
91
+ /**
92
+ * Route handler (method) Decorator. Routes all HTTP requests to the specified path.
93
+ *
94
+ * @see [Routing](https://docs.nestjs.com/controllers#routing)
95
+ *
96
+ * @publicApi
97
+ */
98
+ exports.Search = createMappingDecorator(enums_1.RequestMethod.SEARCH);
@@ -0,0 +1,378 @@
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;
@@ -0,0 +1,227 @@
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;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Declares this route as a Server-Sent-Events endpoint
3
+ *
4
+ * @publicApi
5
+ */
6
+ export declare function Sse(path?: string): MethodDecorator;