@depup/nestjs__core 11.1.17-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.
- package/LICENSE +22 -0
- package/PACKAGE.md +1 -0
- package/README.md +25 -0
- package/Readme.md +146 -0
- package/adapters/http-adapter.d.ts +80 -0
- package/adapters/http-adapter.js +90 -0
- package/adapters/index.d.ts +1 -0
- package/adapters/index.js +4 -0
- package/application-config.d.ts +47 -0
- package/application-config.js +107 -0
- package/changes.json +5 -0
- package/constants.d.ts +14 -0
- package/constants.js +21 -0
- package/discovery/discoverable-meta-host-collection.d.ts +46 -0
- package/discovery/discoverable-meta-host-collection.js +98 -0
- package/discovery/discovery-module.d.ts +5 -0
- package/discovery/discovery-module.js +19 -0
- package/discovery/discovery-service.d.ts +76 -0
- package/discovery/discovery-service.js +98 -0
- package/discovery/index.d.ts +2 -0
- package/discovery/index.js +5 -0
- package/errors/exception-handler.d.ts +4 -0
- package/errors/exception-handler.js +11 -0
- package/errors/exceptions/circular-dependency.exception.d.ts +4 -0
- package/errors/exceptions/circular-dependency.exception.js +11 -0
- package/errors/exceptions/index.d.ts +8 -0
- package/errors/exceptions/index.js +11 -0
- package/errors/exceptions/invalid-class-module.exception.d.ts +4 -0
- package/errors/exceptions/invalid-class-module.exception.js +11 -0
- package/errors/exceptions/invalid-class-scope.exception.d.ts +5 -0
- package/errors/exceptions/invalid-class-scope.exception.js +16 -0
- package/errors/exceptions/invalid-class.exception.d.ts +4 -0
- package/errors/exceptions/invalid-class.exception.js +11 -0
- package/errors/exceptions/invalid-exception-filter.exception.d.ts +4 -0
- package/errors/exceptions/invalid-exception-filter.exception.js +11 -0
- package/errors/exceptions/invalid-middleware-configuration.exception.d.ts +4 -0
- package/errors/exceptions/invalid-middleware-configuration.exception.js +11 -0
- package/errors/exceptions/invalid-middleware.exception.d.ts +4 -0
- package/errors/exceptions/invalid-middleware.exception.js +11 -0
- package/errors/exceptions/invalid-module.exception.d.ts +4 -0
- package/errors/exceptions/invalid-module.exception.js +11 -0
- package/errors/exceptions/runtime.exception.d.ts +4 -0
- package/errors/exceptions/runtime.exception.js +12 -0
- package/errors/exceptions/undefined-dependency.exception.d.ts +6 -0
- package/errors/exceptions/undefined-dependency.exception.js +11 -0
- package/errors/exceptions/undefined-forwardref.exception.d.ts +5 -0
- package/errors/exceptions/undefined-forwardref.exception.js +11 -0
- package/errors/exceptions/undefined-module.exception.d.ts +4 -0
- package/errors/exceptions/undefined-module.exception.js +11 -0
- package/errors/exceptions/unknown-dependencies.exception.d.ts +16 -0
- package/errors/exceptions/unknown-dependencies.exception.js +15 -0
- package/errors/exceptions/unknown-element.exception.d.ts +4 -0
- package/errors/exceptions/unknown-element.exception.js +11 -0
- package/errors/exceptions/unknown-export.exception.d.ts +4 -0
- package/errors/exceptions/unknown-export.exception.js +11 -0
- package/errors/exceptions/unknown-module.exception.d.ts +4 -0
- package/errors/exceptions/unknown-module.exception.js +10 -0
- package/errors/exceptions/unknown-request-mapping.exception.d.ts +5 -0
- package/errors/exceptions/unknown-request-mapping.exception.js +11 -0
- package/errors/exceptions-zone.d.ts +5 -0
- package/errors/exceptions-zone.js +34 -0
- package/errors/messages.d.ts +17 -0
- package/errors/messages.js +174 -0
- package/exceptions/base-exception-filter-context.d.ts +14 -0
- package/exceptions/base-exception-filter-context.js +56 -0
- package/exceptions/base-exception-filter.d.ts +20 -0
- package/exceptions/base-exception-filter.js +72 -0
- package/exceptions/exceptions-handler.d.ts +10 -0
- package/exceptions/exceptions-handler.js +34 -0
- package/exceptions/external-exception-filter-context.d.ts +12 -0
- package/exceptions/external-exception-filter-context.js +42 -0
- package/exceptions/external-exception-filter.d.ts +5 -0
- package/exceptions/external-exception-filter.js +15 -0
- package/exceptions/external-exceptions-handler.d.ts +9 -0
- package/exceptions/external-exceptions-handler.js +34 -0
- package/exceptions/index.d.ts +1 -0
- package/exceptions/index.js +4 -0
- package/guards/constants.d.ts +1 -0
- package/guards/constants.js +4 -0
- package/guards/guards-consumer.d.ts +9 -0
- package/guards/guards-consumer.js +39 -0
- package/guards/guards-context-creator.d.ts +17 -0
- package/guards/guards-context-creator.js +70 -0
- package/guards/index.d.ts +3 -0
- package/guards/index.js +6 -0
- package/helpers/barrier.d.ts +30 -0
- package/helpers/barrier.js +46 -0
- package/helpers/context-creator.d.ts +10 -0
- package/helpers/context-creator.js +33 -0
- package/helpers/context-id-factory.d.ts +41 -0
- package/helpers/context-id-factory.js +67 -0
- package/helpers/context-utils.d.ts +23 -0
- package/helpers/context-utils.js +55 -0
- package/helpers/execution-context-host.d.ts +19 -0
- package/helpers/execution-context-host.js +50 -0
- package/helpers/external-context-creator.d.ts +51 -0
- package/helpers/external-context-creator.js +166 -0
- package/helpers/external-proxy.d.ts +5 -0
- package/helpers/external-proxy.js +19 -0
- package/helpers/get-class-scope.d.ts +3 -0
- package/helpers/get-class-scope.js +8 -0
- package/helpers/handler-metadata-storage.d.ts +27 -0
- package/helpers/handler-metadata-storage.js +26 -0
- package/helpers/http-adapter-host.d.ts +51 -0
- package/helpers/http-adapter-host.js +73 -0
- package/helpers/index.d.ts +3 -0
- package/helpers/index.js +6 -0
- package/helpers/interfaces/external-handler-metadata.interface.d.ts +11 -0
- package/helpers/interfaces/external-handler-metadata.interface.js +2 -0
- package/helpers/interfaces/index.d.ts +2 -0
- package/helpers/interfaces/index.js +5 -0
- package/helpers/interfaces/params-metadata.interface.d.ts +6 -0
- package/helpers/interfaces/params-metadata.interface.js +2 -0
- package/helpers/is-durable.d.ts +2 -0
- package/helpers/is-durable.js +8 -0
- package/helpers/load-adapter.d.ts +1 -0
- package/helpers/load-adapter.js +15 -0
- package/helpers/messages.d.ts +7 -0
- package/helpers/messages.js +29 -0
- package/helpers/optional-require.d.ts +1 -0
- package/helpers/optional-require.js +11 -0
- package/helpers/rethrow.d.ts +1 -0
- package/helpers/rethrow.js +7 -0
- package/helpers/router-method-factory.d.ts +23 -0
- package/helpers/router-method-factory.js +33 -0
- package/hooks/before-app-shutdown.hook.d.ts +9 -0
- package/hooks/before-app-shutdown.hook.js +51 -0
- package/hooks/index.d.ts +5 -0
- package/hooks/index.js +8 -0
- package/hooks/on-app-bootstrap.hook.d.ts +8 -0
- package/hooks/on-app-bootstrap.hook.js +53 -0
- package/hooks/on-app-shutdown.hook.d.ts +9 -0
- package/hooks/on-app-shutdown.hook.js +54 -0
- package/hooks/on-module-destroy.hook.d.ts +8 -0
- package/hooks/on-module-destroy.hook.js +53 -0
- package/hooks/on-module-init.hook.d.ts +8 -0
- package/hooks/on-module-init.hook.js +53 -0
- package/hooks/utils/get-instances-grouped-by-hierarchy-level.d.ts +3 -0
- package/hooks/utils/get-instances-grouped-by-hierarchy-level.js +27 -0
- package/hooks/utils/get-sorted-hierarchy-levels.d.ts +1 -0
- package/hooks/utils/get-sorted-hierarchy-levels.js +7 -0
- package/index.d.ts +17 -0
- package/index.js +32 -0
- package/injector/abstract-instance-resolver.d.ts +16 -0
- package/injector/abstract-instance-resolver.js +49 -0
- package/injector/compiler.d.ts +18 -0
- package/injector/compiler.js +35 -0
- package/injector/constants.d.ts +3 -0
- package/injector/constants.js +8 -0
- package/injector/container.d.ts +67 -0
- package/injector/container.js +233 -0
- package/injector/helpers/provider-classifier.d.ts +4 -0
- package/injector/helpers/provider-classifier.js +16 -0
- package/injector/helpers/silent-logger.d.ts +10 -0
- package/injector/helpers/silent-logger.js +18 -0
- package/injector/helpers/transient-instances.d.ts +12 -0
- package/injector/helpers/transient-instances.js +28 -0
- package/injector/index.d.ts +6 -0
- package/injector/index.js +8 -0
- package/injector/injector.d.ts +104 -0
- package/injector/injector.js +554 -0
- package/injector/inquirer/index.d.ts +1 -0
- package/injector/inquirer/index.js +4 -0
- package/injector/inquirer/inquirer-constants.d.ts +1 -0
- package/injector/inquirer/inquirer-constants.js +4 -0
- package/injector/inquirer/inquirer-providers.d.ts +2 -0
- package/injector/inquirer/inquirer-providers.js +11 -0
- package/injector/instance-links-host.d.ts +22 -0
- package/injector/instance-links-host.js +56 -0
- package/injector/instance-loader.d.ts +23 -0
- package/injector/instance-loader.js +88 -0
- package/injector/instance-wrapper.d.ts +99 -0
- package/injector/instance-wrapper.js +350 -0
- package/injector/internal-core-module/index.d.ts +1 -0
- package/injector/internal-core-module/index.js +4 -0
- package/injector/internal-core-module/internal-core-module-factory.d.ts +9 -0
- package/injector/internal-core-module/internal-core-module-factory.js +52 -0
- package/injector/internal-core-module/internal-core-module.d.ts +5 -0
- package/injector/internal-core-module/internal-core-module.js +40 -0
- package/injector/internal-providers-storage.d.ts +9 -0
- package/injector/internal-providers-storage.js +19 -0
- package/injector/lazy-module-loader/lazy-module-loader-options.interface.d.ts +6 -0
- package/injector/lazy-module-loader/lazy-module-loader-options.interface.js +2 -0
- package/injector/lazy-module-loader/lazy-module-loader.d.ts +20 -0
- package/injector/lazy-module-loader/lazy-module-loader.js +49 -0
- package/injector/module-ref.d.ts +106 -0
- package/injector/module-ref.js +66 -0
- package/injector/module.d.ts +82 -0
- package/injector/module.js +432 -0
- package/injector/modules-container.d.ts +27 -0
- package/injector/modules-container.js +42 -0
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.d.ts +15 -0
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.js +41 -0
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.d.ts +15 -0
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.js +83 -0
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.d.ts +18 -0
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.js +2 -0
- package/injector/settlement-signal.d.ts +37 -0
- package/injector/settlement-signal.js +55 -0
- package/injector/topology-tree/topology-tree.d.ts +8 -0
- package/injector/topology-tree/topology-tree.js +51 -0
- package/injector/topology-tree/tree-node.d.ts +14 -0
- package/injector/topology-tree/tree-node.js +54 -0
- package/inspector/deterministic-uuid-registry.d.ts +6 -0
- package/inspector/deterministic-uuid-registry.js +24 -0
- package/inspector/graph-inspector.d.ts +26 -0
- package/inspector/graph-inspector.js +166 -0
- package/inspector/index.d.ts +4 -0
- package/inspector/index.js +7 -0
- package/inspector/initialize-on-preview.allowlist.d.ts +6 -0
- package/inspector/initialize-on-preview.allowlist.js +13 -0
- package/inspector/interfaces/edge.interface.d.ts +28 -0
- package/inspector/interfaces/edge.interface.js +2 -0
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +12 -0
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +2 -0
- package/inspector/interfaces/entrypoint.interface.d.ts +23 -0
- package/inspector/interfaces/entrypoint.interface.js +2 -0
- package/inspector/interfaces/extras.interface.d.ts +18 -0
- package/inspector/interfaces/extras.interface.js +2 -0
- package/inspector/interfaces/node.interface.d.ts +48 -0
- package/inspector/interfaces/node.interface.js +2 -0
- package/inspector/interfaces/serialized-graph-json.interface.d.ts +14 -0
- package/inspector/interfaces/serialized-graph-json.interface.js +2 -0
- package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +10 -0
- package/inspector/interfaces/serialized-graph-metadata.interface.js +2 -0
- package/inspector/noop-graph-inspector.d.ts +2 -0
- package/inspector/noop-graph-inspector.js +8 -0
- package/inspector/partial-graph.host.d.ts +7 -0
- package/inspector/partial-graph.host.js +15 -0
- package/inspector/serialized-graph.d.ts +52 -0
- package/inspector/serialized-graph.js +124 -0
- package/inspector/uuid-factory.d.ts +9 -0
- package/inspector/uuid-factory.js +22 -0
- package/interceptors/index.d.ts +2 -0
- package/interceptors/index.js +5 -0
- package/interceptors/interceptors-consumer.d.ts +9 -0
- package/interceptors/interceptors-consumer.js +37 -0
- package/interceptors/interceptors-context-creator.d.ts +16 -0
- package/interceptors/interceptors-context-creator.js +69 -0
- package/interfaces/index.d.ts +2 -0
- package/interfaces/index.js +2 -0
- package/interfaces/module-definition.interface.d.ts +3 -0
- package/interfaces/module-definition.interface.js +2 -0
- package/interfaces/module-override.interface.d.ts +5 -0
- package/interfaces/module-override.interface.js +2 -0
- package/internal.d.ts +38 -0
- package/internal.js +46 -0
- package/metadata-scanner.d.ts +17 -0
- package/metadata-scanner.js +83 -0
- package/middleware/builder.d.ts +15 -0
- package/middleware/builder.js +91 -0
- package/middleware/container.d.ts +14 -0
- package/middleware/container.js +49 -0
- package/middleware/index.d.ts +1 -0
- package/middleware/index.js +4 -0
- package/middleware/middleware-module.d.ts +33 -0
- package/middleware/middleware-module.js +208 -0
- package/middleware/resolver.d.ts +10 -0
- package/middleware/resolver.js +18 -0
- package/middleware/route-info-path-extractor.d.ts +15 -0
- package/middleware/route-info-path-extractor.js +81 -0
- package/middleware/routes-mapper.d.ts +19 -0
- package/middleware/routes-mapper.js +117 -0
- package/middleware/utils.d.ts +8 -0
- package/middleware/utils.js +106 -0
- package/nest-application-context.d.ts +173 -0
- package/nest-application-context.js +327 -0
- package/nest-application.d.ts +64 -0
- package/nest-application.js +328 -0
- package/nest-factory.d.ts +83 -0
- package/nest-factory.js +232 -0
- package/package.json +73 -0
- package/pipes/index.d.ts +3 -0
- package/pipes/index.js +6 -0
- package/pipes/params-token-factory.d.ts +5 -0
- package/pipes/params-token-factory.js +19 -0
- package/pipes/pipes-consumer.d.ts +10 -0
- package/pipes/pipes-consumer.js +21 -0
- package/pipes/pipes-context-creator.d.ts +17 -0
- package/pipes/pipes-context-creator.js +72 -0
- package/repl/assign-to-object.util.d.ts +5 -0
- package/repl/assign-to-object.util.js +14 -0
- package/repl/constants.d.ts +1 -0
- package/repl/constants.js +4 -0
- package/repl/index.d.ts +1 -0
- package/repl/index.js +4 -0
- package/repl/native-functions/debug-repl-fn.d.ts +9 -0
- package/repl/native-functions/debug-repl-fn.js +46 -0
- package/repl/native-functions/get-repl-fn.d.ts +7 -0
- package/repl/native-functions/get-repl-fn.js +19 -0
- package/repl/native-functions/help-repl-fn.d.ts +7 -0
- package/repl/native-functions/help-repl-fn.js +29 -0
- package/repl/native-functions/index.d.ts +6 -0
- package/repl/native-functions/index.js +9 -0
- package/repl/native-functions/methods-repl-fn.d.ts +8 -0
- package/repl/native-functions/methods-repl-fn.js +28 -0
- package/repl/native-functions/resolve-repl-fn.d.ts +7 -0
- package/repl/native-functions/resolve-repl-fn.js +18 -0
- package/repl/native-functions/select-relp-fn.d.ts +7 -0
- package/repl/native-functions/select-relp-fn.js +18 -0
- package/repl/repl-context.d.ts +26 -0
- package/repl/repl-context.js +126 -0
- package/repl/repl-function.d.ts +18 -0
- package/repl/repl-function.js +19 -0
- package/repl/repl-logger.d.ts +5 -0
- package/repl/repl-logger.js +22 -0
- package/repl/repl-native-commands.d.ts +2 -0
- package/repl/repl-native-commands.js +46 -0
- package/repl/repl.d.ts +3 -0
- package/repl/repl.interfaces.d.ts +16 -0
- package/repl/repl.interfaces.js +2 -0
- package/repl/repl.js +32 -0
- package/router/index.d.ts +3 -0
- package/router/index.js +8 -0
- package/router/interfaces/exceptions-filter.interface.d.ts +6 -0
- package/router/interfaces/exceptions-filter.interface.js +2 -0
- package/router/interfaces/exclude-route-metadata.interface.d.ts +15 -0
- package/router/interfaces/exclude-route-metadata.interface.js +2 -0
- package/router/interfaces/index.d.ts +1 -0
- package/router/interfaces/index.js +4 -0
- package/router/interfaces/resolver.interface.d.ts +5 -0
- package/router/interfaces/resolver.interface.js +2 -0
- package/router/interfaces/route-params-factory.interface.d.ts +8 -0
- package/router/interfaces/route-params-factory.interface.js +2 -0
- package/router/interfaces/route-path-metadata.interface.d.ts +32 -0
- package/router/interfaces/route-path-metadata.interface.js +2 -0
- package/router/interfaces/routes.interface.d.ts +7 -0
- package/router/interfaces/routes.interface.js +2 -0
- package/router/legacy-route-converter.d.ts +16 -0
- package/router/legacy-route-converter.js +61 -0
- package/router/paths-explorer.d.ts +18 -0
- package/router/paths-explorer.js +45 -0
- package/router/request/index.d.ts +1 -0
- package/router/request/index.js +5 -0
- package/router/request/request-constants.d.ts +2 -0
- package/router/request/request-constants.js +5 -0
- package/router/request/request-providers.d.ts +2 -0
- package/router/request/request-providers.js +11 -0
- package/router/route-params-factory.d.ts +9 -0
- package/router/route-params-factory.js +41 -0
- package/router/route-path-factory.d.ts +14 -0
- package/router/route-path-factory.js +101 -0
- package/router/router-exception-filters.d.ts +14 -0
- package/router/router-exception-filters.js +40 -0
- package/router/router-execution-context.d.ts +54 -0
- package/router/router-execution-context.js +186 -0
- package/router/router-explorer.d.ts +47 -0
- package/router/router-explorer.js +234 -0
- package/router/router-module.d.ts +19 -0
- package/router/router-module.js +80 -0
- package/router/router-proxy.d.ts +6 -0
- package/router/router-proxy.js +31 -0
- package/router/router-response-controller.d.ts +28 -0
- package/router/router-response-controller.js +98 -0
- package/router/routes-resolver.d.ts +27 -0
- package/router/routes-resolver.js +129 -0
- package/router/sse-stream.d.ts +43 -0
- package/router/sse-stream.js +83 -0
- package/router/utils/exclude-route.util.d.ts +4 -0
- package/router/utils/exclude-route.util.js +19 -0
- package/router/utils/flatten-route-paths.util.d.ts +6 -0
- package/router/utils/flatten-route-paths.util.js +25 -0
- package/router/utils/index.d.ts +2 -0
- package/router/utils/index.js +5 -0
- package/scanner.d.ts +89 -0
- package/scanner.js +416 -0
- package/services/index.d.ts +1 -0
- package/services/index.js +4 -0
- package/services/reflector.service.d.ts +111 -0
- package/services/reflector.service.js +100 -0
- package/tsconfig.build.json +21 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoutesMapper = void 0;
|
|
4
|
+
const constants_1 = require("@nestjs/common/constants");
|
|
5
|
+
const interfaces_1 = require("@nestjs/common/interfaces");
|
|
6
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
7
|
+
const metadata_scanner_1 = require("../metadata-scanner");
|
|
8
|
+
const paths_explorer_1 = require("../router/paths-explorer");
|
|
9
|
+
const router_module_1 = require("../router/router-module");
|
|
10
|
+
class RoutesMapper {
|
|
11
|
+
constructor(container, applicationConfig) {
|
|
12
|
+
this.container = container;
|
|
13
|
+
this.applicationConfig = applicationConfig;
|
|
14
|
+
this.pathsExplorer = new paths_explorer_1.PathsExplorer(new metadata_scanner_1.MetadataScanner());
|
|
15
|
+
}
|
|
16
|
+
mapRouteToRouteInfo(controllerOrRoute) {
|
|
17
|
+
if ((0, shared_utils_1.isString)(controllerOrRoute)) {
|
|
18
|
+
return this.getRouteInfoFromPath(controllerOrRoute);
|
|
19
|
+
}
|
|
20
|
+
const routePathOrPaths = this.getRoutePath(controllerOrRoute);
|
|
21
|
+
if (this.isRouteInfo(routePathOrPaths, controllerOrRoute)) {
|
|
22
|
+
return this.getRouteInfoFromObject(controllerOrRoute);
|
|
23
|
+
}
|
|
24
|
+
return this.getRouteInfoFromController(controllerOrRoute, routePathOrPaths);
|
|
25
|
+
}
|
|
26
|
+
getRouteInfoFromPath(routePath) {
|
|
27
|
+
const defaultRequestMethod = -1;
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
path: (0, shared_utils_1.addLeadingSlash)(routePath),
|
|
31
|
+
method: defaultRequestMethod,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
getRouteInfoFromObject(routeInfoObject) {
|
|
36
|
+
const routeInfo = {
|
|
37
|
+
path: (0, shared_utils_1.addLeadingSlash)(routeInfoObject.path),
|
|
38
|
+
method: routeInfoObject.method,
|
|
39
|
+
};
|
|
40
|
+
if (routeInfoObject.version) {
|
|
41
|
+
routeInfo.version = routeInfoObject.version;
|
|
42
|
+
}
|
|
43
|
+
return [routeInfo];
|
|
44
|
+
}
|
|
45
|
+
getRouteInfoFromController(controller, routePath) {
|
|
46
|
+
const controllerPaths = this.pathsExplorer.scanForPaths(Object.create(controller), controller.prototype);
|
|
47
|
+
const controllerVersion = this.getVersionMetadata(controller);
|
|
48
|
+
const versioningConfig = this.applicationConfig.getVersioning();
|
|
49
|
+
const moduleRef = this.getHostModuleOfController(controller);
|
|
50
|
+
const modulePath = this.getModulePath(moduleRef?.metatype);
|
|
51
|
+
const concatPaths = (acc, currentValue) => acc.concat(currentValue);
|
|
52
|
+
const toUndefinedIfNeural = (version) => version === interfaces_1.VERSION_NEUTRAL ? undefined : version;
|
|
53
|
+
const toRouteInfo = (item, prefix) => item.path?.flatMap(p => {
|
|
54
|
+
let endpointPath = modulePath ?? '';
|
|
55
|
+
endpointPath += this.normalizeGlobalPath(prefix) + (0, shared_utils_1.addLeadingSlash)(p);
|
|
56
|
+
const routeInfo = {
|
|
57
|
+
path: endpointPath,
|
|
58
|
+
method: item.requestMethod,
|
|
59
|
+
};
|
|
60
|
+
const version = item.version ?? controllerVersion;
|
|
61
|
+
if (version && versioningConfig) {
|
|
62
|
+
if (typeof version !== 'string' && Array.isArray(version)) {
|
|
63
|
+
return version.map(v => ({
|
|
64
|
+
...routeInfo,
|
|
65
|
+
version: toUndefinedIfNeural(v),
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
routeInfo.version = toUndefinedIfNeural(version);
|
|
69
|
+
}
|
|
70
|
+
return routeInfo;
|
|
71
|
+
});
|
|
72
|
+
return []
|
|
73
|
+
.concat(routePath)
|
|
74
|
+
.map(routePath => controllerPaths
|
|
75
|
+
.map(item => toRouteInfo(item, routePath))
|
|
76
|
+
.reduce(concatPaths, []))
|
|
77
|
+
.reduce(concatPaths, []);
|
|
78
|
+
}
|
|
79
|
+
isRouteInfo(path, objectOrClass) {
|
|
80
|
+
return (0, shared_utils_1.isUndefined)(path);
|
|
81
|
+
}
|
|
82
|
+
normalizeGlobalPath(path) {
|
|
83
|
+
const prefix = (0, shared_utils_1.addLeadingSlash)(path);
|
|
84
|
+
return prefix === '/' ? '' : prefix;
|
|
85
|
+
}
|
|
86
|
+
getRoutePath(route) {
|
|
87
|
+
return Reflect.getMetadata(constants_1.PATH_METADATA, route);
|
|
88
|
+
}
|
|
89
|
+
getHostModuleOfController(metatype) {
|
|
90
|
+
if (!metatype) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const modulesContainer = this.container.getModules();
|
|
94
|
+
const moduleRefsSet = router_module_1.targetModulesByContainer.get(modulesContainer);
|
|
95
|
+
if (!moduleRefsSet) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const modules = Array.from(modulesContainer.values()).filter(moduleRef => moduleRefsSet.has(moduleRef));
|
|
99
|
+
return modules.find(({ controllers }) => controllers.has(metatype));
|
|
100
|
+
}
|
|
101
|
+
getModulePath(metatype) {
|
|
102
|
+
if (!metatype) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const modulesContainer = this.container.getModules();
|
|
106
|
+
const modulePath = Reflect.getMetadata(constants_1.MODULE_PATH + modulesContainer.applicationId, metatype);
|
|
107
|
+
return modulePath ?? Reflect.getMetadata(constants_1.MODULE_PATH, metatype);
|
|
108
|
+
}
|
|
109
|
+
getVersionMetadata(metatype) {
|
|
110
|
+
const versioningConfig = this.applicationConfig.getVersioning();
|
|
111
|
+
if (versioningConfig) {
|
|
112
|
+
return (Reflect.getMetadata(constants_1.VERSION_METADATA, metatype) ??
|
|
113
|
+
versioningConfig.defaultVersion);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.RoutesMapper = RoutesMapper;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpServer, RouteInfo, Type } from '@nestjs/common/interfaces';
|
|
2
|
+
import { ExcludeRouteMetadata } from '../router/interfaces/exclude-route-metadata.interface';
|
|
3
|
+
export declare const mapToExcludeRoute: (routes: (string | RouteInfo)[]) => ExcludeRouteMetadata[];
|
|
4
|
+
export declare const filterMiddleware: <T extends Function | Type<any> = any>(middleware: T[], routes: RouteInfo[], httpAdapter: HttpServer) => Type<any>[];
|
|
5
|
+
export declare const mapToClass: <T extends Function | Type<any>>(middleware: T, excludedRoutes: ExcludeRouteMetadata[], httpAdapter: HttpServer) => Type<any>;
|
|
6
|
+
export declare function isMiddlewareClass(middleware: any): middleware is Type<any>;
|
|
7
|
+
export declare function assignToken(metatype: Type<any>, token?: string): Type<any>;
|
|
8
|
+
export declare function isMiddlewareRouteExcluded(req: Record<string, any>, excludedRoutes: ExcludeRouteMetadata[], httpAdapter: HttpServer): boolean;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapToClass = exports.filterMiddleware = exports.mapToExcludeRoute = void 0;
|
|
4
|
+
exports.isMiddlewareClass = isMiddlewareClass;
|
|
5
|
+
exports.assignToken = assignToken;
|
|
6
|
+
exports.isMiddlewareRouteExcluded = isMiddlewareRouteExcluded;
|
|
7
|
+
const common_1 = require("@nestjs/common");
|
|
8
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
9
|
+
const iterare_1 = require("iterare");
|
|
10
|
+
const path_to_regexp_1 = require("path-to-regexp");
|
|
11
|
+
const uid_1 = require("uid");
|
|
12
|
+
const legacy_route_converter_1 = require("../router/legacy-route-converter");
|
|
13
|
+
const utils_1 = require("../router/utils");
|
|
14
|
+
const mapToExcludeRoute = (routes) => {
|
|
15
|
+
return routes.map(route => {
|
|
16
|
+
const originalPath = (0, shared_utils_1.isString)(route) ? route : route.path;
|
|
17
|
+
const path = legacy_route_converter_1.LegacyRouteConverter.tryConvert(originalPath);
|
|
18
|
+
try {
|
|
19
|
+
if ((0, shared_utils_1.isString)(route)) {
|
|
20
|
+
return {
|
|
21
|
+
path,
|
|
22
|
+
requestMethod: common_1.RequestMethod.ALL,
|
|
23
|
+
pathRegex: (0, path_to_regexp_1.pathToRegexp)((0, shared_utils_1.addLeadingSlash)(path)).regexp,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
path,
|
|
28
|
+
requestMethod: route.method,
|
|
29
|
+
pathRegex: (0, path_to_regexp_1.pathToRegexp)((0, shared_utils_1.addLeadingSlash)(path)).regexp,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
if (e instanceof TypeError) {
|
|
34
|
+
legacy_route_converter_1.LegacyRouteConverter.printError(originalPath);
|
|
35
|
+
}
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
exports.mapToExcludeRoute = mapToExcludeRoute;
|
|
41
|
+
const filterMiddleware = (middleware, routes, httpAdapter) => {
|
|
42
|
+
const excludedRoutes = (0, exports.mapToExcludeRoute)(routes);
|
|
43
|
+
return (0, iterare_1.iterate)([])
|
|
44
|
+
.concat(middleware)
|
|
45
|
+
.filter(shared_utils_1.isFunction)
|
|
46
|
+
.map((item) => (0, exports.mapToClass)(item, excludedRoutes, httpAdapter))
|
|
47
|
+
.toArray();
|
|
48
|
+
};
|
|
49
|
+
exports.filterMiddleware = filterMiddleware;
|
|
50
|
+
const mapToClass = (middleware, excludedRoutes, httpAdapter) => {
|
|
51
|
+
if (isMiddlewareClass(middleware)) {
|
|
52
|
+
if (excludedRoutes.length <= 0) {
|
|
53
|
+
return middleware;
|
|
54
|
+
}
|
|
55
|
+
const MiddlewareHost = class extends middleware {
|
|
56
|
+
use(...params) {
|
|
57
|
+
const [req, _, next] = params;
|
|
58
|
+
const isExcluded = isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter);
|
|
59
|
+
if (isExcluded) {
|
|
60
|
+
return next();
|
|
61
|
+
}
|
|
62
|
+
return super.use(...params);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return assignToken(MiddlewareHost, middleware.name);
|
|
66
|
+
}
|
|
67
|
+
return assignToken(class {
|
|
68
|
+
constructor() {
|
|
69
|
+
this.use = (...params) => {
|
|
70
|
+
const [req, _, next] = params;
|
|
71
|
+
const isExcluded = isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter);
|
|
72
|
+
if (isExcluded) {
|
|
73
|
+
return next();
|
|
74
|
+
}
|
|
75
|
+
return middleware(...params);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
exports.mapToClass = mapToClass;
|
|
81
|
+
function isMiddlewareClass(middleware) {
|
|
82
|
+
const middlewareStr = middleware.toString();
|
|
83
|
+
if (middlewareStr.substring(0, 5) === 'class') {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
const middlewareArr = middlewareStr.split(' ');
|
|
87
|
+
return (middlewareArr[0] === 'function' &&
|
|
88
|
+
/[A-Z]/.test(middlewareArr[1]?.[0]) &&
|
|
89
|
+
(0, shared_utils_1.isFunction)(middleware.prototype?.use));
|
|
90
|
+
}
|
|
91
|
+
function assignToken(metatype, token = (0, uid_1.uid)(21)) {
|
|
92
|
+
Object.defineProperty(metatype, 'name', { value: token });
|
|
93
|
+
return metatype;
|
|
94
|
+
}
|
|
95
|
+
function isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter) {
|
|
96
|
+
if (excludedRoutes.length <= 0) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const reqMethod = httpAdapter.getRequestMethod(req);
|
|
100
|
+
const originalUrl = httpAdapter.getRequestUrl(req);
|
|
101
|
+
const queryParamsIndex = originalUrl ? originalUrl.indexOf('?') : -1;
|
|
102
|
+
const pathname = queryParamsIndex >= 0
|
|
103
|
+
? originalUrl.slice(0, queryParamsIndex)
|
|
104
|
+
: originalUrl;
|
|
105
|
+
return (0, utils_1.isRouteExcluded)(excludedRoutes, pathname, common_1.RequestMethod[reqMethod]);
|
|
106
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { INestApplicationContext, Logger, LoggerService, LogLevel, ShutdownSignal } from '@nestjs/common';
|
|
2
|
+
import { DynamicModule, SelectOptions, ShutdownHooksOptions, Type } from '@nestjs/common/interfaces';
|
|
3
|
+
import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
|
|
4
|
+
import { AbstractInstanceResolver } from './injector/abstract-instance-resolver';
|
|
5
|
+
import { NestContainer } from './injector/container';
|
|
6
|
+
import { Injector } from './injector/injector';
|
|
7
|
+
import { InstanceLinksHost } from './injector/instance-links-host';
|
|
8
|
+
import { ContextId } from './injector/instance-wrapper';
|
|
9
|
+
import { Module } from './injector/module';
|
|
10
|
+
/**
|
|
11
|
+
* @publicApi
|
|
12
|
+
*/
|
|
13
|
+
export declare class NestApplicationContext<TOptions extends NestApplicationContextOptions = NestApplicationContextOptions> extends AbstractInstanceResolver implements INestApplicationContext {
|
|
14
|
+
protected readonly container: NestContainer;
|
|
15
|
+
protected readonly appOptions: TOptions;
|
|
16
|
+
private contextModule;
|
|
17
|
+
private readonly scope;
|
|
18
|
+
protected isInitialized: boolean;
|
|
19
|
+
protected injector: Injector;
|
|
20
|
+
protected readonly logger: Logger;
|
|
21
|
+
private shouldFlushLogsOnOverride;
|
|
22
|
+
private readonly activeShutdownSignals;
|
|
23
|
+
private readonly moduleCompiler;
|
|
24
|
+
private shutdownCleanupRef?;
|
|
25
|
+
private _instanceLinksHost;
|
|
26
|
+
private _moduleRefsForHooksByDistance?;
|
|
27
|
+
private initializationPromise?;
|
|
28
|
+
protected get instanceLinksHost(): InstanceLinksHost;
|
|
29
|
+
constructor(container: NestContainer, appOptions?: TOptions, contextModule?: Module | null, scope?: Type<any>[]);
|
|
30
|
+
selectContextModule(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Allows navigating through the modules tree, for example, to pull out a specific instance from the selected module.
|
|
33
|
+
* @returns {INestApplicationContext}
|
|
34
|
+
*/
|
|
35
|
+
select<T>(moduleType: Type<T> | DynamicModule, selectOptions?: SelectOptions): INestApplicationContext;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves an instance of either injectable or controller, otherwise, throws exception.
|
|
38
|
+
* @returns {TResult}
|
|
39
|
+
*/
|
|
40
|
+
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol): TResult;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves an instance of either injectable or controller, otherwise, throws exception.
|
|
43
|
+
* @returns {TResult}
|
|
44
|
+
*/
|
|
45
|
+
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options: {
|
|
46
|
+
strict?: boolean;
|
|
47
|
+
each?: undefined | false;
|
|
48
|
+
}): TResult;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves a list of instances of either injectables or controllers, otherwise, throws exception.
|
|
51
|
+
* @returns {Array<TResult>}
|
|
52
|
+
*/
|
|
53
|
+
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options: {
|
|
54
|
+
strict?: boolean;
|
|
55
|
+
each: true;
|
|
56
|
+
}): Array<TResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
|
|
59
|
+
* @returns {Array<TResult>}
|
|
60
|
+
*/
|
|
61
|
+
resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol): Promise<TResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
|
|
64
|
+
* @returns {Array<TResult>}
|
|
65
|
+
*/
|
|
66
|
+
resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
|
|
67
|
+
id: number;
|
|
68
|
+
}): Promise<TResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
|
|
71
|
+
* @returns {Array<TResult>}
|
|
72
|
+
*/
|
|
73
|
+
resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
|
|
74
|
+
id: number;
|
|
75
|
+
}, options?: {
|
|
76
|
+
strict?: boolean;
|
|
77
|
+
each?: undefined | false;
|
|
78
|
+
}): Promise<TResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Resolves transient or request-scoped instances of either injectables or controllers, otherwise, throws exception.
|
|
81
|
+
* @returns {Array<TResult>}
|
|
82
|
+
*/
|
|
83
|
+
resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
|
|
84
|
+
id: number;
|
|
85
|
+
}, options?: {
|
|
86
|
+
strict?: boolean;
|
|
87
|
+
each: true;
|
|
88
|
+
}): Promise<Array<TResult>>;
|
|
89
|
+
/**
|
|
90
|
+
* Registers the request/context object for a given context ID (DI container sub-tree).
|
|
91
|
+
* @returns {void}
|
|
92
|
+
*/
|
|
93
|
+
registerRequestByContextId<T = any>(request: T, contextId: ContextId): void;
|
|
94
|
+
/**
|
|
95
|
+
* Initializes the Nest application.
|
|
96
|
+
* Calls the Nest lifecycle events.
|
|
97
|
+
*
|
|
98
|
+
* @returns {Promise<this>} The NestApplicationContext instance as Promise
|
|
99
|
+
*/
|
|
100
|
+
init(): Promise<this>;
|
|
101
|
+
/**
|
|
102
|
+
* Terminates the application
|
|
103
|
+
* @returns {Promise<void>}
|
|
104
|
+
*/
|
|
105
|
+
close(signal?: string): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Sets custom logger service.
|
|
108
|
+
* Flushes buffered logs if auto flush is on.
|
|
109
|
+
* @returns {void}
|
|
110
|
+
*/
|
|
111
|
+
useLogger(logger: LoggerService | LogLevel[] | false): void;
|
|
112
|
+
/**
|
|
113
|
+
* Prints buffered logs and detaches buffer.
|
|
114
|
+
* @returns {void}
|
|
115
|
+
*/
|
|
116
|
+
flushLogs(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Define that it must flush logs right after defining a custom logger.
|
|
119
|
+
*/
|
|
120
|
+
flushLogsOnOverride(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Enables the usage of shutdown hooks. Will call the
|
|
123
|
+
* `onApplicationShutdown` function of a provider if the
|
|
124
|
+
* process receives a shutdown signal.
|
|
125
|
+
*
|
|
126
|
+
* @param {ShutdownSignal[]} [signals=[]] The system signals it should listen to
|
|
127
|
+
* @param {ShutdownHooksOptions} [options={}] Options for configuring shutdown hooks behavior
|
|
128
|
+
*
|
|
129
|
+
* @returns {this} The Nest application context instance
|
|
130
|
+
*/
|
|
131
|
+
enableShutdownHooks(signals?: (ShutdownSignal | string)[], options?: ShutdownHooksOptions): this;
|
|
132
|
+
protected dispose(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Listens to shutdown signals by listening to
|
|
135
|
+
* process events
|
|
136
|
+
*
|
|
137
|
+
* @param {string[]} signals The system signals it should listen to
|
|
138
|
+
* @param {ShutdownHooksOptions} options Options for configuring shutdown hooks behavior
|
|
139
|
+
*/
|
|
140
|
+
protected listenToShutdownSignals(signals: string[], options?: ShutdownHooksOptions): void;
|
|
141
|
+
/**
|
|
142
|
+
* Unsubscribes from shutdown signals (process events)
|
|
143
|
+
*/
|
|
144
|
+
protected unsubscribeFromProcessSignals(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Calls the `onModuleInit` function on the registered
|
|
147
|
+
* modules and its children.
|
|
148
|
+
*/
|
|
149
|
+
protected callInitHook(): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Calls the `onModuleDestroy` function on the registered
|
|
152
|
+
* modules and its children.
|
|
153
|
+
*/
|
|
154
|
+
protected callDestroyHook(): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Calls the `onApplicationBootstrap` function on the registered
|
|
157
|
+
* modules and its children.
|
|
158
|
+
*/
|
|
159
|
+
protected callBootstrapHook(): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Calls the `onApplicationShutdown` function on the registered
|
|
162
|
+
* modules and children.
|
|
163
|
+
*/
|
|
164
|
+
protected callShutdownHook(signal?: string): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Calls the `beforeApplicationShutdown` function on the registered
|
|
167
|
+
* modules and children.
|
|
168
|
+
*/
|
|
169
|
+
protected callBeforeShutdownHook(signal?: string): Promise<void>;
|
|
170
|
+
protected assertNotInPreviewMode(methodName: string): void;
|
|
171
|
+
private getModulesToTriggerHooksOn;
|
|
172
|
+
private printInPreviewModeWarning;
|
|
173
|
+
}
|