@depup/nestjs__core 11.2.3-depup.0 → 12.0.2-depup.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 (361) hide show
  1. package/README.md +2 -2
  2. package/adapters/http-adapter.d.ts +372 -3
  3. package/adapters/http-adapter.js +135 -5
  4. package/adapters/index.d.ts +1 -1
  5. package/adapters/index.js +1 -4
  6. package/application-config.d.ts +13 -4
  7. package/application-config.js +34 -15
  8. package/changes.json +1 -1
  9. package/constants.d.ts +1 -1
  10. package/constants.js +10 -13
  11. package/discovery/discoverable-meta-host-collection.d.ts +3 -3
  12. package/discovery/discoverable-meta-host-collection.js +25 -20
  13. package/discovery/discovery-module.js +9 -12
  14. package/discovery/discovery-service.d.ts +4 -4
  15. package/discovery/discovery-service.js +17 -19
  16. package/discovery/index.d.ts +2 -2
  17. package/discovery/index.js +2 -5
  18. package/errors/exception-handler.js +3 -7
  19. package/errors/exceptions/circular-dependency.exception.d.ts +1 -1
  20. package/errors/exceptions/circular-dependency.exception.js +2 -6
  21. package/errors/exceptions/index.d.ts +9 -8
  22. package/errors/exceptions/index.js +9 -11
  23. package/errors/exceptions/invalid-class-module.exception.d.ts +1 -1
  24. package/errors/exceptions/invalid-class-module.exception.js +4 -8
  25. package/errors/exceptions/invalid-class-scope.exception.d.ts +2 -2
  26. package/errors/exceptions/invalid-class-scope.exception.js +6 -10
  27. package/errors/exceptions/invalid-class.exception.d.ts +1 -1
  28. package/errors/exceptions/invalid-class.exception.js +4 -8
  29. package/errors/exceptions/invalid-exception-filter.exception.d.ts +1 -1
  30. package/errors/exceptions/invalid-exception-filter.exception.js +4 -8
  31. package/errors/exceptions/invalid-middleware-configuration.exception.d.ts +1 -1
  32. package/errors/exceptions/invalid-middleware-configuration.exception.js +4 -8
  33. package/errors/exceptions/invalid-middleware.exception.d.ts +1 -1
  34. package/errors/exceptions/invalid-middleware.exception.js +4 -8
  35. package/errors/exceptions/invalid-module.exception.d.ts +1 -1
  36. package/errors/exceptions/invalid-module.exception.js +4 -8
  37. package/errors/exceptions/route-conflict.exception.d.ts +4 -0
  38. package/errors/exceptions/route-conflict.exception.js +7 -0
  39. package/errors/exceptions/runtime.exception.js +1 -5
  40. package/errors/exceptions/undefined-dependency.exception.d.ts +3 -3
  41. package/errors/exceptions/undefined-dependency.exception.js +4 -8
  42. package/errors/exceptions/undefined-forwardref.exception.d.ts +2 -2
  43. package/errors/exceptions/undefined-forwardref.exception.js +4 -8
  44. package/errors/exceptions/undefined-module.exception.d.ts +1 -1
  45. package/errors/exceptions/undefined-module.exception.js +4 -8
  46. package/errors/exceptions/unknown-dependencies.exception.d.ts +3 -3
  47. package/errors/exceptions/unknown-dependencies.exception.js +8 -8
  48. package/errors/exceptions/unknown-element.exception.d.ts +1 -1
  49. package/errors/exceptions/unknown-element.exception.js +2 -6
  50. package/errors/exceptions/unknown-export.exception.d.ts +1 -1
  51. package/errors/exceptions/unknown-export.exception.js +4 -8
  52. package/errors/exceptions/unknown-module.exception.d.ts +1 -1
  53. package/errors/exceptions/unknown-module.exception.js +2 -6
  54. package/errors/exceptions/unknown-request-mapping.exception.d.ts +1 -1
  55. package/errors/exceptions/unknown-request-mapping.exception.js +4 -8
  56. package/errors/exceptions-zone.js +6 -10
  57. package/errors/messages.d.ts +5 -2
  58. package/errors/messages.js +26 -32
  59. package/exceptions/base-exception-filter-context.d.ts +6 -7
  60. package/exceptions/base-exception-filter-context.js +13 -16
  61. package/exceptions/base-exception-filter.d.ts +4 -4
  62. package/exceptions/base-exception-filter.js +46 -23
  63. package/exceptions/exceptions-handler.d.ts +4 -4
  64. package/exceptions/exceptions-handler.js +8 -16
  65. package/exceptions/external-exception-filter-context.d.ts +8 -8
  66. package/exceptions/external-exception-filter-context.js +14 -18
  67. package/exceptions/external-exception-filter.d.ts +1 -1
  68. package/exceptions/external-exception-filter.js +4 -8
  69. package/exceptions/external-exceptions-handler.d.ts +3 -3
  70. package/exceptions/external-exceptions-handler.js +8 -16
  71. package/exceptions/index.d.ts +1 -1
  72. package/exceptions/index.js +1 -4
  73. package/guards/constants.js +1 -4
  74. package/guards/guards-consumer.d.ts +4 -3
  75. package/guards/guards-consumer.js +8 -12
  76. package/guards/guards-context-creator.d.ts +11 -10
  77. package/guards/guards-context-creator.js +18 -20
  78. package/guards/index.d.ts +3 -3
  79. package/guards/index.js +3 -6
  80. package/helpers/barrier.js +5 -5
  81. package/helpers/context-creator.d.ts +2 -2
  82. package/helpers/context-creator.js +3 -7
  83. package/helpers/context-id-factory.d.ts +1 -1
  84. package/helpers/context-id-factory.js +10 -14
  85. package/helpers/context-utils.d.ts +6 -3
  86. package/helpers/context-utils.js +7 -12
  87. package/helpers/execution-context-host.d.ts +3 -3
  88. package/helpers/execution-context-host.js +5 -6
  89. package/helpers/external-context-creator.d.ts +15 -18
  90. package/helpers/external-context-creator.js +54 -43
  91. package/helpers/external-proxy.d.ts +2 -2
  92. package/helpers/external-proxy.js +3 -7
  93. package/helpers/get-class-scope.d.ts +2 -2
  94. package/helpers/get-class-scope.js +3 -6
  95. package/helpers/handler-metadata-storage.d.ts +4 -4
  96. package/helpers/handler-metadata-storage.js +7 -15
  97. package/helpers/http-adapter-host.d.ts +1 -1
  98. package/helpers/http-adapter-host.js +6 -11
  99. package/helpers/index.d.ts +3 -3
  100. package/helpers/index.js +3 -6
  101. package/helpers/interfaces/external-handler-metadata.interface.d.ts +2 -2
  102. package/helpers/interfaces/external-handler-metadata.interface.js +1 -2
  103. package/helpers/interfaces/index.d.ts +2 -2
  104. package/helpers/interfaces/index.js +2 -5
  105. package/helpers/interfaces/params-metadata.interface.d.ts +1 -1
  106. package/helpers/interfaces/params-metadata.interface.js +1 -2
  107. package/helpers/is-durable.d.ts +1 -1
  108. package/helpers/is-durable.js +3 -6
  109. package/helpers/load-adapter.d.ts +1 -1
  110. package/helpers/load-adapter.js +5 -8
  111. package/helpers/messages.d.ts +1 -1
  112. package/helpers/messages.js +10 -20
  113. package/helpers/optional-require.d.ts +1 -1
  114. package/helpers/optional-require.js +2 -5
  115. package/helpers/rethrow.js +1 -5
  116. package/helpers/router-method-factory.d.ts +2 -2
  117. package/helpers/router-method-factory.js +21 -25
  118. package/helpers/safe-instance-decorator.js +3 -6
  119. package/hooks/before-app-shutdown.hook.d.ts +3 -3
  120. package/hooks/before-app-shutdown.hook.js +25 -23
  121. package/hooks/index.d.ts +5 -5
  122. package/hooks/index.js +5 -8
  123. package/hooks/on-app-bootstrap.hook.d.ts +3 -3
  124. package/hooks/on-app-bootstrap.hook.js +15 -22
  125. package/hooks/on-app-shutdown.hook.d.ts +3 -3
  126. package/hooks/on-app-shutdown.hook.js +25 -23
  127. package/hooks/on-module-destroy.hook.d.ts +3 -3
  128. package/hooks/on-module-destroy.hook.js +25 -23
  129. package/hooks/on-module-init.hook.d.ts +3 -3
  130. package/hooks/on-module-init.hook.js +15 -22
  131. package/hooks/utils/get-instances-grouped-by-hierarchy-level.d.ts +3 -0
  132. package/hooks/utils/get-instances-grouped-by-hierarchy-level.js +27 -0
  133. package/hooks/utils/get-sorted-hierarchy-levels.d.ts +1 -0
  134. package/hooks/utils/get-sorted-hierarchy-levels.js +7 -0
  135. package/index.d.ts +16 -16
  136. package/index.js +17 -26
  137. package/injector/abstract-instance-resolver.d.ts +6 -6
  138. package/injector/abstract-instance-resolver.js +7 -11
  139. package/injector/compiler.d.ts +2 -2
  140. package/injector/compiler.js +2 -5
  141. package/injector/constants.d.ts +1 -1
  142. package/injector/constants.js +2 -5
  143. package/injector/container.d.ts +13 -14
  144. package/injector/container.js +40 -40
  145. package/injector/helpers/is-debug-mode.util.d.ts +1 -0
  146. package/injector/helpers/is-debug-mode.util.js +3 -0
  147. package/injector/helpers/provider-classifier.d.ts +1 -1
  148. package/injector/helpers/provider-classifier.js +5 -10
  149. package/injector/helpers/silent-logger.js +9 -16
  150. package/injector/index.d.ts +6 -6
  151. package/injector/index.js +5 -8
  152. package/injector/injector.d.ts +7 -7
  153. package/injector/injector.js +104 -93
  154. package/injector/inquirer/index.d.ts +1 -1
  155. package/injector/inquirer/index.js +1 -4
  156. package/injector/inquirer/inquirer-constants.js +1 -4
  157. package/injector/inquirer/inquirer-providers.d.ts +1 -1
  158. package/injector/inquirer/inquirer-providers.js +5 -8
  159. package/injector/instance-links-host.d.ts +3 -3
  160. package/injector/instance-links-host.js +8 -11
  161. package/injector/instance-loader.d.ts +5 -5
  162. package/injector/instance-loader.js +17 -11
  163. package/injector/instance-wrapper.d.ts +8 -6
  164. package/injector/instance-wrapper.js +98 -81
  165. package/injector/internal-core-module/index.d.ts +1 -1
  166. package/injector/internal-core-module/index.js +1 -4
  167. package/injector/internal-core-module/internal-core-module-factory.d.ts +6 -6
  168. package/injector/internal-core-module/internal-core-module-factory.js +23 -27
  169. package/injector/internal-core-module/internal-core-module.d.ts +2 -2
  170. package/injector/internal-core-module/internal-core-module.js +17 -20
  171. package/injector/internal-providers-storage.d.ts +2 -2
  172. package/injector/internal-providers-storage.js +4 -9
  173. package/injector/lazy-module-loader/lazy-module-loader-options.interface.js +1 -2
  174. package/injector/lazy-module-loader/lazy-module-loader.d.ts +8 -8
  175. package/injector/lazy-module-loader/lazy-module-loader.js +36 -27
  176. package/injector/module-ref.d.ts +7 -7
  177. package/injector/module-ref.js +30 -35
  178. package/injector/module.d.ts +5 -5
  179. package/injector/module.js +97 -83
  180. package/injector/modules-container.d.ts +1 -1
  181. package/injector/modules-container.js +5 -12
  182. package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.d.ts +2 -4
  183. package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.js +6 -9
  184. package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.d.ts +2 -3
  185. package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.js +17 -22
  186. package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.d.ts +1 -3
  187. package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.js +1 -2
  188. package/injector/settlement-signal.js +5 -7
  189. package/injector/topology-tree/topology-tree.d.ts +1 -1
  190. package/injector/topology-tree/topology-tree.js +6 -9
  191. package/injector/topology-tree/tree-node.js +4 -6
  192. package/inspector/deterministic-uuid-registry.js +2 -6
  193. package/inspector/graph-inspector.d.ts +7 -7
  194. package/inspector/graph-inspector.js +10 -12
  195. package/inspector/index.d.ts +4 -4
  196. package/inspector/index.js +4 -7
  197. package/inspector/initialize-on-preview.allowlist.d.ts +1 -1
  198. package/inspector/initialize-on-preview.allowlist.js +2 -6
  199. package/inspector/interfaces/edge.interface.d.ts +1 -1
  200. package/inspector/interfaces/edge.interface.js +1 -2
  201. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +3 -3
  202. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +1 -2
  203. package/inspector/interfaces/entrypoint.interface.d.ts +2 -2
  204. package/inspector/interfaces/entrypoint.interface.js +1 -2
  205. package/inspector/interfaces/extras.interface.d.ts +1 -1
  206. package/inspector/interfaces/extras.interface.js +1 -2
  207. package/inspector/interfaces/node.interface.d.ts +2 -2
  208. package/inspector/interfaces/node.interface.js +1 -2
  209. package/inspector/interfaces/serialized-graph-json.interface.d.ts +6 -6
  210. package/inspector/interfaces/serialized-graph-json.interface.js +1 -2
  211. package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +1 -1
  212. package/inspector/interfaces/serialized-graph-metadata.interface.js +1 -2
  213. package/inspector/noop-graph-inspector.d.ts +1 -1
  214. package/inspector/noop-graph-inspector.js +2 -5
  215. package/inspector/partial-graph.host.d.ts +2 -2
  216. package/inspector/partial-graph.host.js +2 -5
  217. package/inspector/serialized-graph.d.ts +7 -7
  218. package/inspector/serialized-graph.js +35 -40
  219. package/inspector/uuid-factory.js +8 -12
  220. package/interceptors/index.d.ts +2 -2
  221. package/interceptors/index.js +2 -5
  222. package/interceptors/interceptors-consumer.d.ts +4 -3
  223. package/interceptors/interceptors-consumer.js +14 -18
  224. package/interceptors/interceptors-context-creator.d.ts +10 -9
  225. package/interceptors/interceptors-context-creator.js +18 -20
  226. package/interfaces/index.d.ts +2 -0
  227. package/interfaces/index.js +2 -0
  228. package/interfaces/module-definition.interface.d.ts +2 -2
  229. package/interfaces/module-definition.interface.js +1 -2
  230. package/interfaces/module-override.interface.d.ts +1 -1
  231. package/interfaces/module-override.interface.js +1 -2
  232. package/internal.d.ts +42 -0
  233. package/internal.js +50 -0
  234. package/metadata-scanner.d.ts +1 -1
  235. package/metadata-scanner.js +8 -14
  236. package/middleware/builder.d.ts +4 -4
  237. package/middleware/builder.js +82 -80
  238. package/middleware/container.d.ts +4 -4
  239. package/middleware/container.js +10 -13
  240. package/middleware/index.d.ts +1 -1
  241. package/middleware/index.js +1 -4
  242. package/middleware/middleware-module.d.ts +8 -9
  243. package/middleware/middleware-module.js +49 -46
  244. package/middleware/resolver.d.ts +3 -3
  245. package/middleware/resolver.js +3 -5
  246. package/middleware/route-info-path-extractor.d.ts +2 -2
  247. package/middleware/route-info-path-extractor.js +26 -25
  248. package/middleware/routes-mapper.d.ts +4 -3
  249. package/middleware/routes-mapper.js +22 -24
  250. package/middleware/utils.d.ts +3 -2
  251. package/middleware/utils.js +34 -45
  252. package/nest-application-context.d.ts +26 -11
  253. package/nest-application-context.js +79 -67
  254. package/nest-application.d.ts +19 -11
  255. package/nest-application.js +168 -65
  256. package/nest-factory.d.ts +4 -5
  257. package/nest-factory.js +61 -68
  258. package/package.json +17 -9
  259. package/pipes/index.d.ts +3 -3
  260. package/pipes/index.js +3 -6
  261. package/pipes/params-token-factory.d.ts +2 -2
  262. package/pipes/params-token-factory.js +5 -9
  263. package/pipes/pipes-consumer.d.ts +3 -7
  264. package/pipes/pipes-consumer.js +17 -18
  265. package/pipes/pipes-context-creator.d.ts +10 -9
  266. package/pipes/pipes-context-creator.js +18 -20
  267. package/repl/assign-to-object.util.js +1 -4
  268. package/repl/constants.js +1 -4
  269. package/repl/index.d.ts +1 -1
  270. package/repl/index.js +1 -4
  271. package/repl/native-functions/debug-repl-fn.d.ts +2 -2
  272. package/repl/native-functions/debug-repl-fn.js +14 -21
  273. package/repl/native-functions/get-repl-fn.d.ts +2 -2
  274. package/repl/native-functions/get-repl-fn.js +8 -15
  275. package/repl/native-functions/help-repl-fn.d.ts +2 -2
  276. package/repl/native-functions/help-repl-fn.js +13 -20
  277. package/repl/native-functions/index.d.ts +6 -6
  278. package/repl/native-functions/index.js +6 -9
  279. package/repl/native-functions/methods-repl-fn.d.ts +2 -2
  280. package/repl/native-functions/methods-repl-fn.js +12 -19
  281. package/repl/native-functions/resolve-repl-fn.d.ts +2 -2
  282. package/repl/native-functions/resolve-repl-fn.js +7 -14
  283. package/repl/native-functions/select-relp-fn.d.ts +2 -2
  284. package/repl/native-functions/select-relp-fn.js +7 -14
  285. package/repl/repl-context.d.ts +3 -3
  286. package/repl/repl-context.js +21 -23
  287. package/repl/repl-function.d.ts +3 -3
  288. package/repl/repl-function.js +5 -7
  289. package/repl/repl-logger.js +10 -14
  290. package/repl/repl-native-commands.js +1 -4
  291. package/repl/repl.d.ts +1 -1
  292. package/repl/repl.interfaces.d.ts +2 -2
  293. package/repl/repl.interfaces.js +1 -2
  294. package/repl/repl.js +17 -20
  295. package/router/index.d.ts +3 -3
  296. package/router/index.js +3 -8
  297. package/router/interfaces/exceptions-filter.interface.d.ts +3 -3
  298. package/router/interfaces/exceptions-filter.interface.js +1 -2
  299. package/router/interfaces/exclude-route-metadata.interface.d.ts +1 -1
  300. package/router/interfaces/exclude-route-metadata.interface.js +1 -2
  301. package/router/interfaces/index.d.ts +4 -1
  302. package/router/interfaces/index.js +4 -4
  303. package/router/interfaces/resolved-route.interface.d.ts +32 -0
  304. package/router/interfaces/resolved-route.interface.js +1 -0
  305. package/router/interfaces/resolver.interface.d.ts +5 -1
  306. package/router/interfaces/resolver.interface.js +1 -2
  307. package/router/interfaces/route-conflict.interface.d.ts +14 -0
  308. package/router/interfaces/route-conflict.interface.js +1 -0
  309. package/router/interfaces/route-params-factory.interface.d.ts +1 -1
  310. package/router/interfaces/route-params-factory.interface.js +1 -2
  311. package/router/interfaces/route-path-metadata.interface.d.ts +2 -2
  312. package/router/interfaces/route-path-metadata.interface.js +1 -2
  313. package/router/interfaces/route-resolution-options.interface.d.ts +24 -0
  314. package/router/interfaces/route-resolution-options.interface.js +1 -0
  315. package/router/interfaces/routes.interface.d.ts +1 -1
  316. package/router/interfaces/routes.interface.js +1 -2
  317. package/router/legacy-route-converter.js +3 -7
  318. package/router/paths-explorer.d.ts +4 -5
  319. package/router/paths-explorer.js +11 -15
  320. package/router/request/index.d.ts +1 -1
  321. package/router/request/index.js +1 -5
  322. package/router/request/request-constants.js +2 -5
  323. package/router/request/request-providers.d.ts +1 -1
  324. package/router/request/request-providers.js +5 -8
  325. package/router/route-conflict-detector.d.ts +71 -0
  326. package/router/route-conflict-detector.js +276 -0
  327. package/router/route-params-factory.d.ts +2 -2
  328. package/router/route-params-factory.js +15 -19
  329. package/router/route-path-factory.d.ts +4 -4
  330. package/router/route-path-factory.js +19 -22
  331. package/router/route-specificity-sorter.d.ts +23 -0
  332. package/router/route-specificity-sorter.js +59 -0
  333. package/router/router-exception-filters.d.ts +9 -9
  334. package/router/router-exception-filters.js +15 -18
  335. package/router/router-execution-context.d.ts +17 -20
  336. package/router/router-execution-context.js +62 -55
  337. package/router/router-explorer.d.ts +25 -18
  338. package/router/router-explorer.js +116 -73
  339. package/router/router-module.d.ts +4 -4
  340. package/router/router-module.js +21 -23
  341. package/router/router-proxy.d.ts +1 -1
  342. package/router/router-proxy.js +4 -8
  343. package/router/router-response-controller.d.ts +2 -2
  344. package/router/router-response-controller.js +23 -27
  345. package/router/routes-resolver.d.ts +13 -11
  346. package/router/routes-resolver.js +42 -55
  347. package/router/sse-stream.d.ts +2 -1
  348. package/router/sse-stream.js +29 -24
  349. package/router/utils/exclude-route.util.d.ts +1 -1
  350. package/router/utils/exclude-route.util.js +7 -12
  351. package/router/utils/flatten-route-paths.util.d.ts +2 -2
  352. package/router/utils/flatten-route-paths.util.js +4 -7
  353. package/router/utils/index.d.ts +2 -2
  354. package/router/utils/index.js +2 -5
  355. package/scanner.d.ts +11 -11
  356. package/scanner.js +66 -67
  357. package/services/index.d.ts +1 -1
  358. package/services/index.js +1 -4
  359. package/services/reflector.service.d.ts +1 -1
  360. package/services/reflector.service.js +9 -13
  361. package/tsconfig.build.json +1 -9
@@ -1,38 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoutesResolver = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const constants_1 = require("@nestjs/common/constants");
6
- const logger_service_1 = require("@nestjs/common/services/logger.service");
7
- const messages_1 = require("../helpers/messages");
8
- const metadata_scanner_1 = require("../metadata-scanner");
9
- const route_path_factory_1 = require("./route-path-factory");
10
- const router_exception_filters_1 = require("./router-exception-filters");
11
- const router_explorer_1 = require("./router-explorer");
12
- const router_proxy_1 = require("./router-proxy");
13
- class RoutesResolver {
1
+ import { Logger, NotFoundException, } from '@nestjs/common';
2
+ import { HOST_METADATA, MODULE_PATH, VERSION_METADATA, } from '@nestjs/common/internal';
3
+ import { CONTROLLER_MAPPING_MESSAGE, VERSIONED_CONTROLLER_MAPPING_MESSAGE, } from '../helpers/messages.js';
4
+ import { MetadataScanner } from '../metadata-scanner.js';
5
+ import { RoutePathFactory } from './route-path-factory.js';
6
+ import { RouterExceptionFilters } from './router-exception-filters.js';
7
+ import { RouterExplorer } from './router-explorer.js';
8
+ import { RouterProxy } from './router-proxy.js';
9
+ export class RoutesResolver {
10
+ container;
11
+ applicationConfig;
12
+ injector;
13
+ logger = new Logger(RoutesResolver.name, {
14
+ timestamp: true,
15
+ });
16
+ routerProxy = new RouterProxy();
17
+ routePathFactory;
18
+ routerExceptionsFilter;
19
+ routerExplorer;
14
20
  constructor(container, applicationConfig, injector, graphInspector) {
15
21
  this.container = container;
16
22
  this.applicationConfig = applicationConfig;
17
23
  this.injector = injector;
18
- this.logger = new logger_service_1.Logger(RoutesResolver.name, {
19
- timestamp: true,
20
- });
21
- this.routerProxy = new router_proxy_1.RouterProxy();
22
24
  const httpAdapterRef = container.getHttpAdapterRef();
23
- this.routerExceptionsFilter = new router_exception_filters_1.RouterExceptionFilters(container, applicationConfig, httpAdapterRef);
24
- this.routePathFactory = new route_path_factory_1.RoutePathFactory(this.applicationConfig);
25
- const metadataScanner = new metadata_scanner_1.MetadataScanner();
26
- this.routerExplorer = new router_explorer_1.RouterExplorer(metadataScanner, this.container, this.injector, this.routerProxy, this.routerExceptionsFilter, this.applicationConfig, this.routePathFactory, graphInspector);
25
+ this.routerExceptionsFilter = new RouterExceptionFilters(container, applicationConfig, httpAdapterRef);
26
+ this.routePathFactory = new RoutePathFactory(this.applicationConfig);
27
+ const metadataScanner = new MetadataScanner();
28
+ this.routerExplorer = new RouterExplorer(metadataScanner, this.container, this.injector, this.routerProxy, this.routerExceptionsFilter, this.applicationConfig, this.routePathFactory, graphInspector);
27
29
  }
28
- resolve(applicationRef, globalPrefix) {
30
+ resolve(applicationRef, globalPrefix, options = {}) {
29
31
  const modules = this.container.getModules();
30
32
  modules.forEach(({ controllers, metatype }, moduleName) => {
31
33
  const modulePath = this.getModulePathMetadata(metatype);
32
- this.registerRouters(controllers, moduleName, globalPrefix, modulePath, applicationRef);
34
+ this.registerRouters(controllers, moduleName, globalPrefix, modulePath, applicationRef, options);
33
35
  });
34
36
  }
35
- registerRouters(routes, moduleName, globalPrefix, modulePath, applicationRef) {
37
+ registerResolvedRoute(applicationRef, route) {
38
+ this.routerExplorer.registerResolvedRoute(applicationRef, route);
39
+ }
40
+ registerRouters(routes, moduleName, globalPrefix, modulePath, applicationRef, options = {}) {
36
41
  routes.forEach(instanceWrapper => {
37
42
  const { metatype } = instanceWrapper;
38
43
  const host = this.getHostMetadata(metatype);
@@ -47,13 +52,13 @@ class RoutesResolver {
47
52
  });
48
53
  if (!controllerVersion) {
49
54
  pathsToLog.forEach(path => {
50
- const logMessage = (0, messages_1.CONTROLLER_MAPPING_MESSAGE)(controllerName, path);
55
+ const logMessage = CONTROLLER_MAPPING_MESSAGE(controllerName, path);
51
56
  this.logger.log(logMessage);
52
57
  });
53
58
  }
54
59
  else {
55
60
  pathsToLog.forEach(path => {
56
- const logMessage = (0, messages_1.VERSIONED_CONTROLLER_MAPPING_MESSAGE)(controllerName, path, controllerVersion);
61
+ const logMessage = VERSIONED_CONTROLLER_MAPPING_MESSAGE(controllerName, path, controllerVersion);
57
62
  this.logger.log(logMessage);
58
63
  });
59
64
  }
@@ -65,7 +70,7 @@ class RoutesResolver {
65
70
  controllerVersion,
66
71
  versioningOptions,
67
72
  };
68
- this.routerExplorer.explore(instanceWrapper, moduleName, applicationRef, host, routePathMetadata);
73
+ this.routerExplorer.explore(instanceWrapper, moduleName, applicationRef, host, routePathMetadata, options);
69
74
  });
70
75
  });
71
76
  }
@@ -74,56 +79,38 @@ class RoutesResolver {
74
79
  const callback = (req, res) => {
75
80
  const method = applicationRef.getRequestMethod(req);
76
81
  const url = applicationRef.getRequestUrl(req);
77
- throw new common_1.NotFoundException(`Cannot ${method} ${url}`);
82
+ throw new NotFoundException(`Cannot ${method} ${url}`);
78
83
  };
79
84
  const handler = this.routerExceptionsFilter.create({}, callback, undefined);
80
85
  const proxy = this.routerProxy.createProxy(callback, handler);
86
+ const prefix = this.applicationConfig.getGlobalPrefix();
81
87
  applicationRef.setNotFoundHandler &&
82
- applicationRef.setNotFoundHandler(proxy, this.applicationConfig.getGlobalPrefix());
88
+ applicationRef.setNotFoundHandler(proxy, prefix);
83
89
  }
84
90
  registerExceptionHandler() {
85
91
  const callback = (err, req, res, next) => {
86
- throw this.mapExternalException(err);
92
+ throw this.container.getHttpAdapterRef().mapException(err);
87
93
  };
88
94
  const handler = this.routerExceptionsFilter.create({}, callback, undefined);
89
95
  const proxy = this.routerProxy.createExceptionLayerProxy(callback, handler);
90
96
  const applicationRef = this.container.getHttpAdapterRef();
97
+ const prefix = this.applicationConfig.getGlobalPrefix();
91
98
  applicationRef.setErrorHandler &&
92
- applicationRef.setErrorHandler(proxy, this.applicationConfig.getGlobalPrefix());
93
- }
94
- mapExternalException(err) {
95
- switch (true) {
96
- // SyntaxError is thrown by Express body-parser when given invalid JSON (#422, #430)
97
- // URIError is thrown by Express when given a path parameter with an invalid percentage
98
- // encoding, e.g. '%FF' (#8915)
99
- case err instanceof SyntaxError || err instanceof URIError:
100
- return new common_1.BadRequestException(err.message);
101
- case this.isHttpFastifyError(err):
102
- return new common_1.HttpException(err.message, err.statusCode);
103
- default:
104
- return err;
105
- }
106
- }
107
- isHttpFastifyError(error) {
108
- // condition based on this code - https://github.com/fastify/fastify-error/blob/d669b150a82968322f9f7be992b2f6b463272de3/index.js#L22
109
- return (error.statusCode !== undefined &&
110
- error instanceof Error &&
111
- error.name === 'FastifyError');
99
+ applicationRef.setErrorHandler(proxy, prefix);
112
100
  }
113
101
  getModulePathMetadata(metatype) {
114
102
  const modulesContainer = this.container.getModules();
115
- const modulePath = Reflect.getMetadata(constants_1.MODULE_PATH + modulesContainer.applicationId, metatype);
116
- return modulePath ?? Reflect.getMetadata(constants_1.MODULE_PATH, metatype);
103
+ const modulePath = Reflect.getMetadata(MODULE_PATH + modulesContainer.applicationId, metatype);
104
+ return modulePath ?? Reflect.getMetadata(MODULE_PATH, metatype);
117
105
  }
118
106
  getHostMetadata(metatype) {
119
- return Reflect.getMetadata(constants_1.HOST_METADATA, metatype);
107
+ return Reflect.getMetadata(HOST_METADATA, metatype);
120
108
  }
121
109
  getVersionMetadata(metatype) {
122
110
  const versioningConfig = this.applicationConfig.getVersioning();
123
111
  if (versioningConfig) {
124
- return (Reflect.getMetadata(constants_1.VERSION_METADATA, metatype) ??
112
+ return (Reflect.getMetadata(VERSION_METADATA, metatype) ??
125
113
  versioningConfig.defaultVersion);
126
114
  }
127
115
  }
128
116
  }
129
- exports.RoutesResolver = RoutesResolver;
@@ -1,6 +1,6 @@
1
- import { MessageEvent } from '@nestjs/common/interfaces';
2
1
  import { IncomingMessage, OutgoingHttpHeaders } from 'http';
3
2
  import { Transform } from 'stream';
3
+ import type { MessageEvent } from '@nestjs/common';
4
4
  export type AdditionalHeaders = Record<string, string[] | string | number | undefined>;
5
5
  interface ReadHeaders {
6
6
  getHeaders?(): AdditionalHeaders;
@@ -33,6 +33,7 @@ export declare class SseStream extends Transform {
33
33
  private _destination;
34
34
  private _statusCode;
35
35
  private _additionalHeaders;
36
+ private readonly _isHttp2;
36
37
  constructor(req?: IncomingMessage);
37
38
  get headersCommitted(): boolean;
38
39
  pipe<T extends WritableHeaderStream>(destination: T, options?: {
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SseStream = void 0;
4
- const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
- const stream_1 = require("stream");
1
+ import { Transform } from 'stream';
2
+ import { isNil, isObject, isUndefined } from '@nestjs/common/internal';
6
3
  function serializeSseLines(value, prefix) {
7
4
  return value
8
5
  .split(/\r\n|\r|\n/)
@@ -10,7 +7,7 @@ function serializeSseLines(value, prefix) {
10
7
  .join('');
11
8
  }
12
9
  function toDataString(data) {
13
- if ((0, shared_utils_1.isObject)(data)) {
10
+ if (isObject(data)) {
14
11
  return toDataString(JSON.stringify(data));
15
12
  }
16
13
  return serializeSseLines(data, 'data: ');
@@ -19,10 +16,10 @@ function toCommentString(comment) {
19
16
  return serializeSseLines(comment, ': ');
20
17
  }
21
18
  function isCommentOnly(message) {
22
- return (!(0, shared_utils_1.isNil)(message.comment) &&
23
- (0, shared_utils_1.isUndefined)(message.data) &&
24
- (0, shared_utils_1.isUndefined)(message.type) &&
25
- (0, shared_utils_1.isUndefined)(message.retry));
19
+ return (!isNil(message.comment) &&
20
+ isUndefined(message.data) &&
21
+ isUndefined(message.type) &&
22
+ isUndefined(message.retry));
26
23
  }
27
24
  /**
28
25
  * Adapted from https://raw.githubusercontent.com/EventSource/node-ssestream
@@ -38,14 +35,21 @@ function isCommentOnly(message) {
38
35
  * If constructed with a HTTP Request, it will optimise the socket for streaming.
39
36
  * If this stream is piped to an HTTP Response, it will set appropriate headers.
40
37
  */
41
- class SseStream extends stream_1.Transform {
38
+ export class SseStream extends Transform {
39
+ lastEventId = null;
40
+ _headersCommitted = false;
41
+ _destination = null;
42
+ _statusCode = 200;
43
+ _additionalHeaders;
44
+ _isHttp2;
42
45
  constructor(req) {
43
46
  super({ objectMode: true });
44
- this.lastEventId = null;
45
- this._headersCommitted = false;
46
- this._destination = null;
47
- this._statusCode = 200;
48
- if (req && req.socket) {
47
+ this._isHttp2 = (req?.httpVersionMajor ?? 1) > 1;
48
+ // Under HTTP/2 these calls are not request-scoped: `setTimeout` is routed
49
+ // to the shared `Http2Session` and the rest to the shared TCP socket, so
50
+ // tuning one SSE request would disable the idle timeout for every stream
51
+ // on that connection. See https://nodejs.org/api/http2.html#requestsocket
52
+ if (req && req.socket && !this._isHttp2) {
49
53
  req.socket.setKeepAlive(true);
50
54
  req.socket.setNoDelay(true);
51
55
  req.socket.setTimeout(0);
@@ -79,9 +83,11 @@ class SseStream extends stream_1.Transform {
79
83
  if (this._destination.writeHead) {
80
84
  this._destination.writeHead(statusCode, {
81
85
  ...additionalHeaders,
82
- // See https://github.com/dunglas/mercure/blob/master/hub/subscribe.go#L124-L130
86
+ // See https://github.com/dunglas/mercure/blob/main/subscribe.go#L347-L362
83
87
  'Content-Type': 'text/event-stream',
84
- Connection: 'keep-alive',
88
+ // Hop-by-hop header, forbidden in HTTP/2
89
+ // https://www.rfc-editor.org/rfc/rfc9113#section-8.2.2
90
+ ...(!this._isHttp2 && { Connection: 'keep-alive' }),
85
91
  // Disable cache, even for old browsers and proxies
86
92
  'Cache-Control': 'private, no-cache, no-store, must-revalidate, max-age=0, no-transform',
87
93
  Pragma: 'no-cache',
@@ -97,10 +103,10 @@ class SseStream extends stream_1.Transform {
97
103
  this.commitHeaders();
98
104
  const sanitize = (val) => String(val).replace(/[\r\n]/g, '');
99
105
  let data = message.type ? `event: ${sanitize(message.type)}\n` : '';
100
- data += !(0, shared_utils_1.isNil)(message.id) ? `id: ${sanitize(message.id)}\n` : '';
101
- data += !(0, shared_utils_1.isNil)(message.retry) ? `retry: ${sanitize(message.retry)}\n` : '';
102
- data += !(0, shared_utils_1.isNil)(message.comment) ? toCommentString(message.comment) : '';
103
- data += !(0, shared_utils_1.isNil)(message.data) ? toDataString(message.data) : '';
106
+ data += !isNil(message.id) ? `id: ${sanitize(message.id)}\n` : '';
107
+ data += !isNil(message.retry) ? `retry: ${sanitize(message.retry)}\n` : '';
108
+ data += !isNil(message.comment) ? toCommentString(message.comment) : '';
109
+ data += !isNil(message.data) ? toDataString(message.data) : '';
104
110
  data += '\n';
105
111
  this.push(data);
106
112
  callback();
@@ -109,7 +115,7 @@ class SseStream extends stream_1.Transform {
109
115
  * Calls `.write` but handles the drain if needed
110
116
  */
111
117
  writeMessage(message, cb) {
112
- if ((0, shared_utils_1.isNil)(message.id) && !isCommentOnly(message)) {
118
+ if (isNil(message.id) && !isCommentOnly(message)) {
113
119
  this.lastEventId++;
114
120
  message.id = this.lastEventId.toString();
115
121
  }
@@ -121,4 +127,3 @@ class SseStream extends stream_1.Transform {
121
127
  }
122
128
  }
123
129
  }
124
- exports.SseStream = SseStream;
@@ -1,4 +1,4 @@
1
1
  import { RequestMethod } from '@nestjs/common';
2
- import { ExcludeRouteMetadata } from '../interfaces/exclude-route-metadata.interface';
2
+ import { ExcludeRouteMetadata } from '../interfaces/exclude-route-metadata.interface.js';
3
3
  export declare const isRequestMethodAll: (method: RequestMethod) => boolean;
4
4
  export declare function isRouteExcluded(excludedRoutes: ExcludeRouteMetadata[], path: string, requestMethod?: RequestMethod): boolean;
@@ -1,18 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRequestMethodAll = void 0;
4
- exports.isRouteExcluded = isRouteExcluded;
5
- const common_1 = require("@nestjs/common");
6
- const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
7
- const isRequestMethodAll = (method) => {
8
- return common_1.RequestMethod.ALL === method || method === -1;
1
+ import { RequestMethod } from '@nestjs/common';
2
+ import { addLeadingSlash } from '@nestjs/common/internal';
3
+ export const isRequestMethodAll = (method) => {
4
+ return RequestMethod.ALL === method || method === -1;
9
5
  };
10
- exports.isRequestMethodAll = isRequestMethodAll;
11
- function isRouteExcluded(excludedRoutes, path, requestMethod) {
6
+ export function isRouteExcluded(excludedRoutes, path, requestMethod) {
12
7
  return excludedRoutes.some(route => {
13
- if ((0, exports.isRequestMethodAll)(route.requestMethod) ||
8
+ if (isRequestMethodAll(route.requestMethod) ||
14
9
  route.requestMethod === requestMethod) {
15
- return route.pathRegex.exec((0, shared_utils_1.addLeadingSlash)(path));
10
+ return route.pathRegex.exec(addLeadingSlash(path));
16
11
  }
17
12
  return false;
18
13
  });
@@ -1,5 +1,5 @@
1
- import { Type } from '@nestjs/common';
2
- import { Routes } from '../interfaces/routes.interface';
1
+ import type { Type } from '@nestjs/common';
2
+ import { Routes } from '../interfaces/routes.interface.js';
3
3
  export declare function flattenRoutePaths(routes: Routes): {
4
4
  module: Type;
5
5
  path: string;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.flattenRoutePaths = flattenRoutePaths;
4
- const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
- function flattenRoutePaths(routes) {
1
+ import { isString, normalizePath } from '@nestjs/common/internal';
2
+ export function flattenRoutePaths(routes) {
6
3
  const result = [];
7
4
  routes.forEach(item => {
8
5
  if (item.module && item.path) {
@@ -11,8 +8,8 @@ function flattenRoutePaths(routes) {
11
8
  if (item.children) {
12
9
  const childrenRef = item.children;
13
10
  childrenRef.forEach(child => {
14
- if (!(0, shared_utils_1.isString)(child) && (0, shared_utils_1.isString)(child.path)) {
15
- child.path = (0, shared_utils_1.normalizePath)((0, shared_utils_1.normalizePath)(item.path) + (0, shared_utils_1.normalizePath)(child.path));
11
+ if (!isString(child) && isString(child.path)) {
12
+ child.path = normalizePath(normalizePath(item.path) + normalizePath(child.path));
16
13
  }
17
14
  else {
18
15
  result.push({ path: item.path, module: child });
@@ -1,2 +1,2 @@
1
- export * from './exclude-route.util';
2
- export * from './flatten-route-paths.util';
1
+ export * from './exclude-route.util.js';
2
+ export * from './flatten-route-paths.util.js';
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./exclude-route.util"), exports);
5
- tslib_1.__exportStar(require("./flatten-route-paths.util"), exports);
1
+ export * from './exclude-route.util.js';
2
+ export * from './flatten-route-paths.util.js';
package/scanner.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { DynamicModule, ForwardReference, Provider } from '@nestjs/common';
2
- import { EnhancerSubtype } from '@nestjs/common/constants';
3
- import { ClassProvider, Controller, ExistingProvider, FactoryProvider, Injectable, Type, ValueProvider } from '@nestjs/common/interfaces';
4
- import { ApplicationConfig } from './application-config';
5
- import { NestContainer } from './injector/container';
6
- import { InstanceWrapper } from './injector/instance-wrapper';
7
- import { Module } from './injector/module';
8
- import { GraphInspector } from './inspector/graph-inspector';
9
- import { ModuleDefinition } from './interfaces/module-definition.interface';
10
- import { ModuleOverride } from './interfaces/module-override.interface';
11
- import { MetadataScanner } from './metadata-scanner';
1
+ import type { DynamicModule, ForwardReference, Provider } from '@nestjs/common';
2
+ import { ApplicationConfig } from './application-config.js';
3
+ import { NestContainer } from './injector/container.js';
4
+ import { InstanceWrapper } from './injector/instance-wrapper.js';
5
+ import { Module } from './injector/module.js';
6
+ import { GraphInspector } from './inspector/graph-inspector.js';
7
+ import { ModuleDefinition } from './interfaces/module-definition.interface.js';
8
+ import { ModuleOverride } from './interfaces/module-override.interface.js';
9
+ import { MetadataScanner } from './metadata-scanner.js';
10
+ import { type EnhancerSubtype, type Controller, type Injectable } from '@nestjs/common/internal';
11
+ import { type ClassProvider, type ExistingProvider, type FactoryProvider, type Type, type ValueProvider } from '@nestjs/common';
12
12
  interface ModulesScanParameters {
13
13
  moduleDefinition: ModuleDefinition;
14
14
  scope?: Type<unknown>[];