@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
@@ -0,0 +1,29 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/exceptions/requested-range-not-satisfiable.exception.ts
18
+ import { HttpException } from "./http.exception.js";
19
+ import { HttpStatus } from "../enums/status.enum.js";
20
+
21
+ class RequestedRangeNotSatisfiableException extends HttpException {
22
+ constructor(info, descriptionOrOptions = "Requested Range Not Satisfiable") {
23
+ const { description, httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
24
+ super(HttpException.createBody(info, description, HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE), HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE, httpExceptionOptions);
25
+ }
26
+ }
27
+ export {
28
+ RequestedRangeNotSatisfiableException
29
+ };
@@ -0,0 +1,29 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/exceptions/service-unavailable.exception.ts
18
+ import { HttpException } from "./http.exception.js";
19
+ import { HttpStatus } from "../enums/status.enum.js";
20
+
21
+ class ServiceUnavailableException extends HttpException {
22
+ constructor(info, descriptionOrOptions = "Service Unavailable") {
23
+ const { description, httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
24
+ super(HttpException.createBody(info, description, HttpStatus.SERVICE_UNAVAILABLE), HttpStatus.SERVICE_UNAVAILABLE, httpExceptionOptions);
25
+ }
26
+ }
27
+ export {
28
+ ServiceUnavailableException
29
+ };
@@ -0,0 +1,29 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/exceptions/too-many-requests.exception.ts
18
+ import { HttpException } from "./http.exception.js";
19
+ import { HttpStatus } from "../enums/status.enum.js";
20
+
21
+ class TooManyRequestsException extends HttpException {
22
+ constructor(info, descriptionOrOptions = "Too Many Requests") {
23
+ const { description, httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
24
+ super(HttpException.createBody(info, description, HttpStatus.TOO_MANY_REQUESTS), HttpStatus.TOO_MANY_REQUESTS, httpExceptionOptions);
25
+ }
26
+ }
27
+ export {
28
+ TooManyRequestsException
29
+ };
@@ -0,0 +1,29 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/exceptions/unauthorized.exception.ts
18
+ import { HttpException } from "./http.exception.js";
19
+ import { HttpStatus } from "../enums/status.enum.js";
20
+
21
+ class UnauthorizedException extends HttpException {
22
+ constructor(info, descriptionOrOptions = "Unauthorized") {
23
+ const { description, httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
24
+ super(HttpException.createBody(info, description, HttpStatus.UNAUTHORIZED), HttpStatus.UNAUTHORIZED, httpExceptionOptions);
25
+ }
26
+ }
27
+ export {
28
+ UnauthorizedException
29
+ };
@@ -0,0 +1,29 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/exceptions/unprocessable-entity.exception.ts
18
+ import { HttpException } from "./http.exception.js";
19
+ import { HttpStatus } from "../enums/status.enum.js";
20
+
21
+ class UnprocessableEntityException extends HttpException {
22
+ constructor(info, descriptionOrOptions = "Unprocessable Entity") {
23
+ const { description, httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
24
+ super(HttpException.createBody(info, description, HttpStatus.UNPROCESSABLE_ENTITY), HttpStatus.UNPROCESSABLE_ENTITY, httpExceptionOptions);
25
+ }
26
+ }
27
+ export {
28
+ UnprocessableEntityException
29
+ };
@@ -0,0 +1,29 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/exceptions/unsupported-media-type.exception.ts
18
+ import { HttpException } from "./http.exception.js";
19
+ import { HttpStatus } from "../enums/status.enum.js";
20
+
21
+ class UnsupportedMediaTypeException extends HttpException {
22
+ constructor(info, descriptionOrOptions = "Unsupported Media Type") {
23
+ const { description, httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
24
+ super(HttpException.createBody(info, description, HttpStatus.UNSUPPORTED_MEDIA_TYPE), HttpStatus.UNSUPPORTED_MEDIA_TYPE, httpExceptionOptions);
25
+ }
26
+ }
27
+ export {
28
+ UnsupportedMediaTypeException
29
+ };
@@ -0,0 +1,29 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/exceptions/uri-too-long.exception.ts
18
+ import { HttpException } from "./http.exception.js";
19
+ import { HttpStatus } from "../enums/status.enum.js";
20
+
21
+ class UriTooLongException extends HttpException {
22
+ constructor(info, descriptionOrOptions = "URI Too Long") {
23
+ const { description, httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
24
+ super(HttpException.createBody(info, description, HttpStatus.URI_TOO_LONG), HttpStatus.URI_TOO_LONG, httpExceptionOptions);
25
+ }
26
+ }
27
+ export {
28
+ UriTooLongException
29
+ };
@@ -0,0 +1,28 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/filters/context.ts
18
+ import { VenokExceptionFilterContext } from "@venok/core";
19
+ import { HttpExceptionFilter } from "../filters/filter.js";
20
+
21
+ class HttpExceptionFiltersContext extends VenokExceptionFilterContext {
22
+ getExceptionFilter() {
23
+ return new HttpExceptionFilter(this.container);
24
+ }
25
+ }
26
+ export {
27
+ HttpExceptionFiltersContext
28
+ };
@@ -0,0 +1,56 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/filters/filter.ts
18
+ import { ApplicationContext, isObject, Logger, MESSAGES } from "@venok/core";
19
+ import { HttpException } from "../exceptions/http.exception.js";
20
+ import { HttpStatus } from "../enums/status.enum.js";
21
+ import { HttpConfig } from "../http/config.js";
22
+
23
+ class HttpExceptionFilter {
24
+ container;
25
+ static logger = new Logger("ExceptionsHandler");
26
+ context;
27
+ constructor(container) {
28
+ this.container = container;
29
+ this.context = new ApplicationContext(container, container.applicationConfig);
30
+ }
31
+ catch(exception, host) {
32
+ const applicationRef = this.context.get(HttpConfig).getHttpAdapterRef();
33
+ const isStandardHttpException = exception instanceof HttpException;
34
+ if (!isStandardHttpException)
35
+ return this.handleUnknownError(exception, host, applicationRef);
36
+ const res = exception.getInfo();
37
+ const message = isObject(res) ? res : { statusCode: exception.getStatus(), error: res };
38
+ const ctx = host.getArgByIndex(0);
39
+ applicationRef.setResponseReply(ctx, message, exception.getStatus());
40
+ }
41
+ handleUnknownError(exception, host, applicationRef) {
42
+ const body = this.isHttpError(exception) ? { statusCode: exception.statusCode, error: exception.message } : { statusCode: HttpStatus.INTERNAL_SERVER_ERROR, error: MESSAGES.UNKNOWN_EXCEPTION_MESSAGE };
43
+ const ctx = host.getArgByIndex(0);
44
+ applicationRef.setResponseReply(ctx, body, body.statusCode);
45
+ return this.isExceptionObject(exception) ? HttpExceptionFilter.logger.error(exception.message, exception.stack) : HttpExceptionFilter.logger.error(exception);
46
+ }
47
+ isExceptionObject(err) {
48
+ return isObject(err) && !!err.message;
49
+ }
50
+ isHttpError(err) {
51
+ return err?.statusCode && err?.message;
52
+ }
53
+ }
54
+ export {
55
+ HttpExceptionFilter
56
+ };
@@ -0,0 +1,69 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/helpers/discovery.helper.ts
18
+ import { SCOPE_OPTIONS_METADATA } from "@venok/core";
19
+ import { HOST_METADATA, PATH_METADATA, VERSION_METADATA } from "../constants.js";
20
+
21
+ class VenokBaseDiscovery {
22
+ meta;
23
+ discovery;
24
+ constructor(meta) {
25
+ this.meta = meta;
26
+ }
27
+ getClass() {
28
+ return this.discovery.class;
29
+ }
30
+ getHandler() {
31
+ return this.discovery.handler;
32
+ }
33
+ setDiscovery(discovery) {
34
+ this.discovery ??= discovery;
35
+ }
36
+ getMeta() {
37
+ return this.meta;
38
+ }
39
+ }
40
+
41
+ class RouteDiscovery extends VenokBaseDiscovery {
42
+ }
43
+
44
+ class ControllerDiscovery extends VenokBaseDiscovery {
45
+ items = [];
46
+ pushItem(item) {
47
+ this.items.push(item);
48
+ }
49
+ getItems() {
50
+ return this.items;
51
+ }
52
+ getPrefixes() {
53
+ return this.meta[PATH_METADATA];
54
+ }
55
+ getHost() {
56
+ return this.meta[HOST_METADATA];
57
+ }
58
+ getScope() {
59
+ return this.meta[SCOPE_OPTIONS_METADATA];
60
+ }
61
+ getVersion() {
62
+ return this.meta[VERSION_METADATA];
63
+ }
64
+ }
65
+ export {
66
+ VenokBaseDiscovery,
67
+ RouteDiscovery,
68
+ ControllerDiscovery
69
+ };
@@ -0,0 +1,41 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/helpers/messages.helper.ts
18
+ import { VERSION_NEUTRAL } from "../interfaces/index.js";
19
+ import { HttpMethod } from "../enums/method.enum.js";
20
+ var ROUTE_MAPPED_MESSAGE = (path, method) => `Mapped {${path}, ${HttpMethod[method]}} route`;
21
+ var VERSIONED_ROUTE_MAPPED_MESSAGE = (path, method, version) => {
22
+ const controllerVersions = Array.isArray(version) ? version : [version];
23
+ const versions = controllerVersions.map((version2) => version2 === VERSION_NEUTRAL ? "Neutral" : version2).join(",");
24
+ return `Mapped {${path}, ${HttpMethod[method]}} (version: ${versions}) route`;
25
+ };
26
+ var CONTROLLER_MAPPING_MESSAGE = (name, path) => `${name} {${path}}:`;
27
+ var VERSIONED_CONTROLLER_MAPPING_MESSAGE = (name, path, version) => {
28
+ const controllerVersions = Array.isArray(version) ? version : [version];
29
+ const versions = controllerVersions.map((version2) => version2 === VERSION_NEUTRAL ? "Neutral" : version2).join(",");
30
+ return `${name} {${path}} (version: ${versions}):`;
31
+ };
32
+ var VENOK_HTTP_SERVER_START = (port) => {
33
+ return `Venok start Http server on port: ${port}`;
34
+ };
35
+ export {
36
+ VERSIONED_ROUTE_MAPPED_MESSAGE,
37
+ VERSIONED_CONTROLLER_MAPPING_MESSAGE,
38
+ VENOK_HTTP_SERVER_START,
39
+ ROUTE_MAPPED_MESSAGE,
40
+ CONTROLLER_MAPPING_MESSAGE
41
+ };
@@ -0,0 +1,69 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/helpers/middleware.helper.ts
18
+ import { isFunction, isString } from "@venok/core";
19
+ import { pathToRegexp } from "path-to-regexp";
20
+ import { uid } from "uid";
21
+ import { addLeadingSlash } from "../helpers/path.helper.js";
22
+ import { HttpMethod } from "../enums/method.enum.js";
23
+ var mapToExcludeRoute = (routes) => {
24
+ return routes.map((route) => {
25
+ if (isString(route)) {
26
+ return {
27
+ path: route,
28
+ requestMethod: HttpMethod.ALL,
29
+ pathRegex: pathToRegexp(addLeadingSlash(route))
30
+ };
31
+ }
32
+ return {
33
+ path: route.path,
34
+ requestMethod: route.method,
35
+ pathRegex: pathToRegexp(addLeadingSlash(route.path))
36
+ };
37
+ });
38
+ };
39
+ var filterMiddleware = (middleware) => {
40
+ return middleware.filter(isFunction).map((item) => mapToClass(item));
41
+ };
42
+ var mapToClass = (middleware) => {
43
+ if (!isMiddlewareClass(middleware)) {
44
+ return assignToken(class {
45
+ use = (...params) => {
46
+ return middleware(...params);
47
+ };
48
+ });
49
+ }
50
+ return middleware;
51
+ };
52
+ var isMiddlewareClass = (middleware) => {
53
+ const middlewareStr = middleware.toString();
54
+ if (middlewareStr.substring(0, 5) === "class")
55
+ return true;
56
+ const middlewareArr = middlewareStr.split(" ");
57
+ return middlewareArr[0] === "function" && /[A-Z]/.test(middlewareArr[1]?.[0]) && isFunction(middleware.prototype?.use);
58
+ };
59
+ var assignToken = (metatype, token = uid(21)) => {
60
+ Object.defineProperty(metatype, "name", { value: token });
61
+ return metatype;
62
+ };
63
+ export {
64
+ mapToExcludeRoute,
65
+ mapToClass,
66
+ isMiddlewareClass,
67
+ filterMiddleware,
68
+ assignToken
69
+ };
@@ -0,0 +1,53 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/helpers/path.helper.ts
18
+ var addLeadingSlash = (path) => {
19
+ return path && typeof path === "string" ? path.charAt(0) !== "/" ? "/" + path : path : "";
20
+ };
21
+ var normalizePath = (path) => {
22
+ return path ? ("/" + path.replace(/\/+$/, "")).replace(/\/+/g, "/") : "/";
23
+ };
24
+ var stripEndSlash = (path) => {
25
+ return path[path.length - 1] === "/" ? path.slice(0, path.length - 1) : path;
26
+ };
27
+ var isWildcard = (path) => {
28
+ return path.includes("*") || path.includes("(.*)");
29
+ };
30
+ var isParam = (path) => {
31
+ return /:[^/()]+/.test(path);
32
+ };
33
+ var isOptionalParam = (path) => {
34
+ return /:[^/()]+\?/.test(path);
35
+ };
36
+ var getPathType = (path) => {
37
+ if (isWildcard(path))
38
+ return "wildcard";
39
+ if (isOptionalParam(path))
40
+ return "optional-param";
41
+ if (isParam(path))
42
+ return "param";
43
+ return "static";
44
+ };
45
+ export {
46
+ stripEndSlash,
47
+ normalizePath,
48
+ isWildcard,
49
+ isParam,
50
+ isOptionalParam,
51
+ getPathType,
52
+ addLeadingSlash
53
+ };
@@ -0,0 +1,54 @@
1
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4
+ r = Reflect.decorate(decorators, target, key, desc);
5
+ else
6
+ for (var i = decorators.length - 1;i >= 0; i--)
7
+ if (d = decorators[i])
8
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
12
+ var __legacyMetadataTS = (k, v) => {
13
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
14
+ return Reflect.metadata(k, v);
15
+ };
16
+
17
+ // packages/http/src/helpers/route.helper.ts
18
+ import { isString } from "@venok/core";
19
+ import { addLeadingSlash, normalizePath } from "./path.helper.js";
20
+ import { HttpMethod } from "../enums/method.enum.js";
21
+ var isRequestMethodAll = (method) => {
22
+ return HttpMethod.ALL === method || method === -1;
23
+ };
24
+ var isRouteExcluded = (excludedRoutes, path, requestMethod) => {
25
+ return excludedRoutes.some((route) => {
26
+ if (isRequestMethodAll(route.requestMethod) || route.requestMethod === requestMethod) {
27
+ return route.pathRegex.exec(addLeadingSlash(path));
28
+ }
29
+ return false;
30
+ });
31
+ };
32
+ var flattenRoutePaths = (routes) => {
33
+ const result = [];
34
+ routes.forEach((item) => {
35
+ if (item.module && item.path)
36
+ result.push({ module: item.module, path: item.path });
37
+ if (item.children) {
38
+ const childrenRef = item.children;
39
+ childrenRef.forEach((child) => {
40
+ if (!isString(child) && child.path)
41
+ child.path = normalizePath(normalizePath(item.path) + normalizePath(child.path));
42
+ else
43
+ result.push({ path: item.path, module: child });
44
+ });
45
+ result.push(...flattenRoutePaths(childrenRef));
46
+ }
47
+ });
48
+ return result;
49
+ };
50
+ export {
51
+ isRouteExcluded,
52
+ isRequestMethodAll,
53
+ flattenRoutePaths
54
+ };