@nestjs/core 11.1.15 → 12.0.0-alpha.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/adapters/http-adapter.d.ts +5 -3
- package/adapters/http-adapter.js +8 -5
- package/adapters/index.d.ts +1 -1
- package/adapters/index.js +1 -4
- package/application-config.d.ts +7 -4
- package/application-config.js +20 -15
- package/constants.d.ts +1 -1
- package/constants.js +10 -13
- package/discovery/discoverable-meta-host-collection.d.ts +3 -3
- package/discovery/discoverable-meta-host-collection.js +15 -19
- package/discovery/discovery-module.js +9 -12
- package/discovery/discovery-service.d.ts +4 -4
- package/discovery/discovery-service.js +17 -19
- package/discovery/index.d.ts +2 -2
- package/discovery/index.js +2 -5
- package/errors/exception-handler.js +3 -7
- package/errors/exceptions/circular-dependency.exception.d.ts +1 -1
- package/errors/exceptions/circular-dependency.exception.js +2 -6
- package/errors/exceptions/index.d.ts +8 -8
- package/errors/exceptions/index.js +8 -11
- package/errors/exceptions/invalid-class-module.exception.d.ts +1 -1
- package/errors/exceptions/invalid-class-module.exception.js +4 -8
- package/errors/exceptions/invalid-class-scope.exception.d.ts +2 -2
- package/errors/exceptions/invalid-class-scope.exception.js +6 -10
- package/errors/exceptions/invalid-class.exception.d.ts +1 -1
- package/errors/exceptions/invalid-class.exception.js +4 -8
- package/errors/exceptions/invalid-exception-filter.exception.d.ts +1 -1
- package/errors/exceptions/invalid-exception-filter.exception.js +4 -8
- package/errors/exceptions/invalid-middleware-configuration.exception.d.ts +1 -1
- package/errors/exceptions/invalid-middleware-configuration.exception.js +4 -8
- package/errors/exceptions/invalid-middleware.exception.d.ts +1 -1
- package/errors/exceptions/invalid-middleware.exception.js +4 -8
- package/errors/exceptions/invalid-module.exception.d.ts +1 -1
- package/errors/exceptions/invalid-module.exception.js +4 -8
- package/errors/exceptions/runtime.exception.js +1 -5
- package/errors/exceptions/undefined-dependency.exception.d.ts +3 -3
- package/errors/exceptions/undefined-dependency.exception.js +4 -8
- package/errors/exceptions/undefined-forwardref.exception.d.ts +2 -2
- package/errors/exceptions/undefined-forwardref.exception.js +4 -8
- package/errors/exceptions/undefined-module.exception.d.ts +1 -1
- package/errors/exceptions/undefined-module.exception.js +4 -8
- package/errors/exceptions/unknown-dependencies.exception.d.ts +3 -3
- package/errors/exceptions/unknown-dependencies.exception.js +8 -8
- package/errors/exceptions/unknown-element.exception.d.ts +1 -1
- package/errors/exceptions/unknown-element.exception.js +2 -6
- package/errors/exceptions/unknown-export.exception.d.ts +1 -1
- package/errors/exceptions/unknown-export.exception.js +4 -8
- package/errors/exceptions/unknown-module.exception.d.ts +1 -1
- package/errors/exceptions/unknown-module.exception.js +2 -6
- package/errors/exceptions/unknown-request-mapping.exception.d.ts +1 -1
- package/errors/exceptions/unknown-request-mapping.exception.js +4 -8
- package/errors/exceptions-zone.js +6 -10
- package/errors/messages.d.ts +2 -2
- package/errors/messages.js +19 -32
- package/exceptions/base-exception-filter-context.d.ts +6 -7
- package/exceptions/base-exception-filter-context.js +13 -16
- package/exceptions/base-exception-filter.d.ts +4 -4
- package/exceptions/base-exception-filter.js +33 -23
- package/exceptions/exceptions-handler.d.ts +4 -4
- package/exceptions/exceptions-handler.js +8 -16
- package/exceptions/external-exception-filter-context.d.ts +8 -8
- package/exceptions/external-exception-filter-context.js +14 -18
- package/exceptions/external-exception-filter.d.ts +1 -1
- package/exceptions/external-exception-filter.js +4 -8
- package/exceptions/external-exceptions-handler.d.ts +3 -3
- package/exceptions/external-exceptions-handler.js +8 -16
- package/exceptions/index.d.ts +1 -1
- package/exceptions/index.js +1 -4
- package/guards/constants.js +1 -4
- package/guards/guards-consumer.d.ts +4 -3
- package/guards/guards-consumer.js +8 -12
- package/guards/guards-context-creator.d.ts +11 -10
- package/guards/guards-context-creator.js +18 -20
- package/guards/index.d.ts +3 -3
- package/guards/index.js +3 -6
- package/helpers/barrier.js +5 -5
- package/helpers/context-creator.d.ts +2 -2
- package/helpers/context-creator.js +3 -7
- package/helpers/context-id-factory.d.ts +1 -1
- package/helpers/context-id-factory.js +10 -14
- package/helpers/context-utils.d.ts +6 -3
- package/helpers/context-utils.js +7 -12
- package/helpers/execution-context-host.d.ts +3 -3
- package/helpers/execution-context-host.js +5 -6
- package/helpers/external-context-creator.d.ts +15 -18
- package/helpers/external-context-creator.js +54 -43
- package/helpers/external-proxy.d.ts +2 -2
- package/helpers/external-proxy.js +3 -7
- package/helpers/get-class-scope.d.ts +2 -2
- package/helpers/get-class-scope.js +3 -6
- package/helpers/handler-metadata-storage.d.ts +4 -4
- package/helpers/handler-metadata-storage.js +7 -15
- package/helpers/http-adapter-host.d.ts +1 -1
- package/helpers/http-adapter-host.js +6 -11
- package/helpers/index.d.ts +3 -3
- package/helpers/index.js +3 -6
- package/helpers/interfaces/external-handler-metadata.interface.d.ts +2 -2
- package/helpers/interfaces/external-handler-metadata.interface.js +1 -2
- package/helpers/interfaces/index.d.ts +2 -2
- package/helpers/interfaces/index.js +2 -5
- package/helpers/interfaces/params-metadata.interface.d.ts +1 -1
- package/helpers/interfaces/params-metadata.interface.js +1 -2
- package/helpers/is-durable.d.ts +1 -1
- package/helpers/is-durable.js +3 -6
- package/helpers/load-adapter.d.ts +1 -1
- package/helpers/load-adapter.js +4 -7
- package/helpers/messages.d.ts +1 -1
- package/helpers/messages.js +10 -20
- package/helpers/optional-require.d.ts +1 -1
- package/helpers/optional-require.js +2 -5
- package/helpers/rethrow.js +1 -5
- package/helpers/router-method-factory.d.ts +2 -2
- package/helpers/router-method-factory.js +20 -24
- package/hooks/before-app-shutdown.hook.d.ts +3 -3
- package/hooks/before-app-shutdown.hook.js +15 -22
- package/hooks/index.d.ts +5 -5
- package/hooks/index.js +5 -8
- package/hooks/on-app-bootstrap.hook.d.ts +3 -3
- package/hooks/on-app-bootstrap.hook.js +15 -22
- package/hooks/on-app-shutdown.hook.d.ts +3 -3
- package/hooks/on-app-shutdown.hook.js +15 -22
- package/hooks/on-module-destroy.hook.d.ts +3 -3
- package/hooks/on-module-destroy.hook.js +15 -22
- package/hooks/on-module-init.hook.d.ts +3 -3
- package/hooks/on-module-init.hook.js +15 -22
- 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 +16 -16
- package/index.js +17 -26
- package/injector/abstract-instance-resolver.d.ts +6 -6
- package/injector/abstract-instance-resolver.js +7 -11
- package/injector/compiler.d.ts +2 -2
- package/injector/compiler.js +2 -5
- package/injector/constants.d.ts +1 -1
- package/injector/constants.js +2 -5
- package/injector/container.d.ts +13 -14
- package/injector/container.js +40 -40
- package/injector/helpers/provider-classifier.d.ts +1 -1
- package/injector/helpers/provider-classifier.js +5 -10
- package/injector/helpers/silent-logger.js +9 -16
- package/injector/index.d.ts +6 -6
- package/injector/index.js +5 -8
- package/injector/injector.d.ts +7 -6
- package/injector/injector.js +78 -78
- package/injector/inquirer/index.d.ts +1 -1
- package/injector/inquirer/index.js +1 -4
- package/injector/inquirer/inquirer-constants.js +1 -4
- package/injector/inquirer/inquirer-providers.d.ts +1 -1
- package/injector/inquirer/inquirer-providers.js +5 -8
- package/injector/instance-links-host.d.ts +3 -3
- package/injector/instance-links-host.js +8 -11
- package/injector/instance-loader.d.ts +5 -5
- package/injector/instance-loader.js +11 -11
- package/injector/instance-wrapper.d.ts +8 -5
- package/injector/instance-wrapper.js +93 -74
- package/injector/internal-core-module/index.d.ts +1 -1
- package/injector/internal-core-module/index.js +1 -4
- package/injector/internal-core-module/internal-core-module-factory.d.ts +6 -6
- package/injector/internal-core-module/internal-core-module-factory.js +23 -27
- package/injector/internal-core-module/internal-core-module.d.ts +2 -2
- package/injector/internal-core-module/internal-core-module.js +17 -20
- package/injector/internal-providers-storage.d.ts +2 -2
- package/injector/internal-providers-storage.js +4 -9
- package/injector/lazy-module-loader/lazy-module-loader-options.interface.js +1 -2
- package/injector/lazy-module-loader/lazy-module-loader.d.ts +8 -8
- package/injector/lazy-module-loader/lazy-module-loader.js +10 -9
- package/injector/module-ref.d.ts +7 -7
- package/injector/module-ref.js +19 -20
- package/injector/module.d.ts +5 -5
- package/injector/module.js +93 -79
- package/injector/modules-container.d.ts +1 -1
- package/injector/modules-container.js +5 -12
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.d.ts +2 -4
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.js +6 -9
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.d.ts +2 -3
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.js +17 -22
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.d.ts +1 -3
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.js +1 -2
- package/injector/settlement-signal.js +5 -7
- package/injector/topology-tree/topology-tree.d.ts +1 -1
- package/injector/topology-tree/topology-tree.js +6 -9
- package/injector/topology-tree/tree-node.js +4 -6
- package/inspector/deterministic-uuid-registry.js +2 -6
- package/inspector/graph-inspector.d.ts +7 -7
- package/inspector/graph-inspector.js +10 -12
- package/inspector/index.d.ts +4 -4
- package/inspector/index.js +4 -7
- package/inspector/initialize-on-preview.allowlist.d.ts +1 -1
- package/inspector/initialize-on-preview.allowlist.js +2 -6
- package/inspector/interfaces/edge.interface.d.ts +1 -1
- package/inspector/interfaces/edge.interface.js +1 -2
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +3 -3
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +1 -2
- package/inspector/interfaces/entrypoint.interface.d.ts +2 -2
- package/inspector/interfaces/entrypoint.interface.js +1 -2
- package/inspector/interfaces/extras.interface.d.ts +1 -1
- package/inspector/interfaces/extras.interface.js +1 -2
- package/inspector/interfaces/node.interface.d.ts +2 -2
- package/inspector/interfaces/node.interface.js +1 -2
- package/inspector/interfaces/serialized-graph-json.interface.d.ts +6 -6
- package/inspector/interfaces/serialized-graph-json.interface.js +1 -2
- package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +1 -1
- package/inspector/interfaces/serialized-graph-metadata.interface.js +1 -2
- package/inspector/noop-graph-inspector.d.ts +1 -1
- package/inspector/noop-graph-inspector.js +2 -5
- package/inspector/partial-graph.host.d.ts +2 -2
- package/inspector/partial-graph.host.js +2 -5
- package/inspector/serialized-graph.d.ts +7 -7
- package/inspector/serialized-graph.js +35 -40
- package/inspector/uuid-factory.js +8 -12
- package/interceptors/index.d.ts +2 -2
- package/interceptors/index.js +2 -5
- package/interceptors/interceptors-consumer.d.ts +4 -3
- package/interceptors/interceptors-consumer.js +13 -17
- package/interceptors/interceptors-context-creator.d.ts +10 -9
- package/interceptors/interceptors-context-creator.js +18 -20
- package/interfaces/index.d.ts +2 -0
- package/interfaces/index.js +2 -0
- package/interfaces/module-definition.interface.d.ts +2 -2
- package/interfaces/module-definition.interface.js +1 -2
- package/interfaces/module-override.interface.d.ts +1 -1
- package/interfaces/module-override.interface.js +1 -2
- package/internal.d.ts +38 -0
- package/internal.js +46 -0
- package/metadata-scanner.d.ts +1 -1
- package/metadata-scanner.js +8 -14
- package/middleware/builder.d.ts +4 -4
- package/middleware/builder.js +78 -76
- package/middleware/container.d.ts +4 -4
- package/middleware/container.js +10 -13
- package/middleware/index.d.ts +1 -1
- package/middleware/index.js +1 -4
- package/middleware/middleware-module.d.ts +8 -9
- package/middleware/middleware-module.js +47 -44
- package/middleware/resolver.d.ts +3 -3
- package/middleware/resolver.js +3 -5
- package/middleware/route-info-path-extractor.d.ts +2 -2
- package/middleware/route-info-path-extractor.js +26 -25
- package/middleware/routes-mapper.d.ts +4 -3
- package/middleware/routes-mapper.js +22 -24
- package/middleware/utils.d.ts +3 -2
- package/middleware/utils.js +34 -45
- package/nest-application-context.d.ts +10 -9
- package/nest-application-context.js +50 -47
- package/nest-application.d.ts +18 -10
- package/nest-application.js +87 -55
- package/nest-factory.d.ts +4 -5
- package/nest-factory.js +61 -68
- package/package.json +32 -3
- package/pipes/index.d.ts +3 -3
- package/pipes/index.js +3 -6
- package/pipes/params-token-factory.d.ts +2 -2
- package/pipes/params-token-factory.js +5 -9
- package/pipes/pipes-consumer.d.ts +3 -7
- package/pipes/pipes-consumer.js +17 -18
- package/pipes/pipes-context-creator.d.ts +10 -9
- package/pipes/pipes-context-creator.js +18 -20
- package/repl/assign-to-object.util.js +1 -4
- package/repl/constants.js +1 -4
- package/repl/index.d.ts +1 -1
- package/repl/index.js +1 -4
- package/repl/native-functions/debug-repl-fn.d.ts +2 -2
- package/repl/native-functions/debug-repl-fn.js +14 -21
- package/repl/native-functions/get-repl-fn.d.ts +2 -2
- package/repl/native-functions/get-repl-fn.js +8 -15
- package/repl/native-functions/help-repl-fn.d.ts +2 -2
- package/repl/native-functions/help-repl-fn.js +13 -20
- package/repl/native-functions/index.d.ts +6 -6
- package/repl/native-functions/index.js +6 -9
- package/repl/native-functions/methods-repl-fn.d.ts +2 -2
- package/repl/native-functions/methods-repl-fn.js +12 -19
- package/repl/native-functions/resolve-repl-fn.d.ts +2 -2
- package/repl/native-functions/resolve-repl-fn.js +7 -14
- package/repl/native-functions/select-relp-fn.d.ts +2 -2
- package/repl/native-functions/select-relp-fn.js +7 -14
- package/repl/repl-context.d.ts +3 -3
- package/repl/repl-context.js +21 -23
- package/repl/repl-function.d.ts +3 -3
- package/repl/repl-function.js +5 -7
- package/repl/repl-logger.js +10 -14
- package/repl/repl-native-commands.js +1 -4
- package/repl/repl.d.ts +1 -1
- package/repl/repl.interfaces.d.ts +2 -2
- package/repl/repl.interfaces.js +1 -2
- package/repl/repl.js +17 -20
- package/router/index.d.ts +3 -3
- package/router/index.js +3 -8
- package/router/interfaces/exceptions-filter.interface.d.ts +3 -3
- package/router/interfaces/exceptions-filter.interface.js +1 -2
- package/router/interfaces/exclude-route-metadata.interface.d.ts +1 -1
- package/router/interfaces/exclude-route-metadata.interface.js +1 -2
- package/router/interfaces/index.d.ts +1 -1
- package/router/interfaces/index.js +1 -4
- package/router/interfaces/resolver.interface.js +1 -2
- package/router/interfaces/route-params-factory.interface.d.ts +1 -1
- package/router/interfaces/route-params-factory.interface.js +1 -2
- package/router/interfaces/route-path-metadata.interface.d.ts +2 -2
- package/router/interfaces/route-path-metadata.interface.js +1 -2
- package/router/interfaces/routes.interface.d.ts +1 -1
- package/router/interfaces/routes.interface.js +1 -2
- package/router/legacy-route-converter.js +3 -7
- package/router/paths-explorer.d.ts +4 -5
- package/router/paths-explorer.js +11 -15
- package/router/request/index.d.ts +1 -1
- package/router/request/index.js +1 -5
- package/router/request/request-constants.js +2 -5
- package/router/request/request-providers.d.ts +1 -1
- package/router/request/request-providers.js +5 -8
- package/router/route-params-factory.d.ts +2 -2
- package/router/route-params-factory.js +15 -19
- package/router/route-path-factory.d.ts +4 -4
- package/router/route-path-factory.js +19 -22
- package/router/router-exception-filters.d.ts +9 -9
- package/router/router-exception-filters.js +15 -18
- package/router/router-execution-context.d.ts +17 -20
- package/router/router-execution-context.js +57 -49
- package/router/router-explorer.d.ts +14 -16
- package/router/router-explorer.js +55 -54
- package/router/router-module.d.ts +4 -4
- package/router/router-module.js +21 -23
- package/router/router-proxy.d.ts +1 -1
- package/router/router-proxy.js +4 -8
- package/router/router-response-controller.d.ts +2 -2
- package/router/router-response-controller.js +20 -23
- package/router/routes-resolver.d.ts +8 -9
- package/router/routes-resolver.js +36 -51
- package/router/sse-stream.d.ts +1 -1
- package/router/sse-stream.js +5 -9
- package/router/utils/exclude-route.util.d.ts +1 -1
- package/router/utils/exclude-route.util.js +7 -12
- package/router/utils/flatten-route-paths.util.d.ts +2 -2
- package/router/utils/flatten-route-paths.util.js +4 -7
- package/router/utils/index.d.ts +2 -2
- package/router/utils/index.js +2 -5
- package/scanner.d.ts +11 -11
- package/scanner.js +64 -65
- package/services/index.d.ts +1 -1
- package/services/index.js +1 -4
- package/services/reflector.service.d.ts +1 -1
- package/services/reflector.service.js +9 -13
- package/tsconfig.build.json +1 -9
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { InvalidMiddlewareException } from '../errors/exceptions/invalid-middleware.exception.js';
|
|
3
|
+
import { RuntimeException } from '../errors/exceptions/runtime.exception.js';
|
|
4
|
+
import { ContextIdFactory } from '../helpers/context-id-factory.js';
|
|
5
|
+
import { ExecutionContextHost } from '../helpers/execution-context-host.js';
|
|
6
|
+
import { STATIC_CONTEXT } from '../injector/constants.js';
|
|
7
|
+
import { REQUEST_CONTEXT_ID } from '../router/request/request-constants.js';
|
|
8
|
+
import { RouterExceptionFilters } from '../router/router-exception-filters.js';
|
|
9
|
+
import { RouterProxy } from '../router/router-proxy.js';
|
|
10
|
+
import { isRequestMethodAll } from '../router/utils/index.js';
|
|
11
|
+
import { MiddlewareBuilder } from './builder.js';
|
|
12
|
+
import { MiddlewareResolver } from './resolver.js';
|
|
13
|
+
import { RouteInfoPathExtractor } from './route-info-path-extractor.js';
|
|
14
|
+
import { RoutesMapper } from './routes-mapper.js';
|
|
15
|
+
import { RequestMethod } from '@nestjs/common';
|
|
16
|
+
import { isUndefined, } from '@nestjs/common/internal';
|
|
17
|
+
export class MiddlewareModule {
|
|
18
|
+
routerProxy = new RouterProxy();
|
|
19
|
+
exceptionFiltersCache = new WeakMap();
|
|
20
|
+
logger = new Logger(MiddlewareModule.name);
|
|
21
|
+
injector;
|
|
22
|
+
routerExceptionFilter;
|
|
23
|
+
routesMapper;
|
|
24
|
+
resolver;
|
|
25
|
+
container;
|
|
26
|
+
httpAdapter;
|
|
27
|
+
graphInspector;
|
|
28
|
+
appOptions;
|
|
29
|
+
routeInfoPathExtractor;
|
|
26
30
|
async register(middlewareContainer, container, config, injector, httpAdapter, graphInspector, options) {
|
|
27
31
|
this.appOptions = options;
|
|
28
32
|
const appRef = container.getHttpAdapterRef();
|
|
29
|
-
this.routerExceptionFilter = new
|
|
30
|
-
this.routesMapper = new
|
|
31
|
-
this.resolver = new
|
|
32
|
-
this.routeInfoPathExtractor = new
|
|
33
|
+
this.routerExceptionFilter = new RouterExceptionFilters(container, config, appRef);
|
|
34
|
+
this.routesMapper = new RoutesMapper(container, config);
|
|
35
|
+
this.resolver = new MiddlewareResolver(middlewareContainer, injector);
|
|
36
|
+
this.routeInfoPathExtractor = new RouteInfoPathExtractor(config);
|
|
33
37
|
this.injector = injector;
|
|
34
38
|
this.container = container;
|
|
35
39
|
this.httpAdapter = httpAdapter;
|
|
@@ -50,7 +54,7 @@ class MiddlewareModule {
|
|
|
50
54
|
if (!instance.configure) {
|
|
51
55
|
return;
|
|
52
56
|
}
|
|
53
|
-
const middlewareBuilder = new
|
|
57
|
+
const middlewareBuilder = new MiddlewareBuilder(this.routesMapper, this.httpAdapter, this.routeInfoPathExtractor);
|
|
54
58
|
try {
|
|
55
59
|
await instance.configure(middlewareBuilder);
|
|
56
60
|
}
|
|
@@ -62,7 +66,7 @@ class MiddlewareModule {
|
|
|
62
66
|
` (possibly due to missing dependencies). Note: you can ignore this message, just be aware that some of those conditional middlewares will not be reflected in your graph.`;
|
|
63
67
|
this.logger.warn(warningMessage);
|
|
64
68
|
}
|
|
65
|
-
if (!(middlewareBuilder instanceof
|
|
69
|
+
if (!(middlewareBuilder instanceof MiddlewareBuilder)) {
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
72
|
const config = middlewareBuilder.build();
|
|
@@ -107,8 +111,8 @@ class MiddlewareModule {
|
|
|
107
111
|
for (const metatype of middlewareCollection) {
|
|
108
112
|
const collection = middlewareContainer.getMiddlewareCollection(moduleKey);
|
|
109
113
|
const instanceWrapper = collection.get(metatype);
|
|
110
|
-
if (
|
|
111
|
-
throw new
|
|
114
|
+
if (isUndefined(instanceWrapper)) {
|
|
115
|
+
throw new RuntimeException();
|
|
112
116
|
}
|
|
113
117
|
if (instanceWrapper.isTransient) {
|
|
114
118
|
return;
|
|
@@ -122,7 +126,7 @@ class MiddlewareModule {
|
|
|
122
126
|
metadata: {
|
|
123
127
|
key: routeInfo.path,
|
|
124
128
|
path: routeInfo.path,
|
|
125
|
-
requestMethod:
|
|
129
|
+
requestMethod: RequestMethod[routeInfo.method] ??
|
|
126
130
|
'ALL',
|
|
127
131
|
version: routeInfo.version,
|
|
128
132
|
},
|
|
@@ -133,8 +137,8 @@ class MiddlewareModule {
|
|
|
133
137
|
}
|
|
134
138
|
async bindHandler(wrapper, applicationRef, routeInfo, moduleRef, collection) {
|
|
135
139
|
const { instance, metatype } = wrapper;
|
|
136
|
-
if (
|
|
137
|
-
throw new
|
|
140
|
+
if (isUndefined(instance?.use)) {
|
|
141
|
+
throw new InvalidMiddlewareException(metatype.name);
|
|
138
142
|
}
|
|
139
143
|
const isStatic = wrapper.isDependencyTreeStatic();
|
|
140
144
|
if (isStatic) {
|
|
@@ -155,12 +159,12 @@ class MiddlewareModule {
|
|
|
155
159
|
exceptionsHandler = this.routerExceptionFilter.create(instance, instance.use, undefined);
|
|
156
160
|
this.exceptionFiltersCache.set(instance.use, exceptionsHandler);
|
|
157
161
|
}
|
|
158
|
-
const host = new
|
|
162
|
+
const host = new ExecutionContextHost([req, res, next]);
|
|
159
163
|
exceptionsHandler.next(err, host);
|
|
160
164
|
}
|
|
161
165
|
});
|
|
162
166
|
}
|
|
163
|
-
async createProxy(instance, contextId =
|
|
167
|
+
async createProxy(instance, contextId = STATIC_CONTEXT) {
|
|
164
168
|
const exceptionsHandler = this.routerExceptionFilter.create(instance, instance.use, undefined, contextId);
|
|
165
169
|
const middleware = instance.use.bind(instance);
|
|
166
170
|
return this.routerProxy.createProxy(middleware, exceptionsHandler);
|
|
@@ -168,8 +172,8 @@ class MiddlewareModule {
|
|
|
168
172
|
async registerHandler(applicationRef, routeInfo, proxy) {
|
|
169
173
|
const { method } = routeInfo;
|
|
170
174
|
const paths = this.routeInfoPathExtractor.extractPathsFrom(routeInfo);
|
|
171
|
-
const isMethodAll =
|
|
172
|
-
const requestMethod =
|
|
175
|
+
const isMethodAll = isRequestMethodAll(method);
|
|
176
|
+
const requestMethod = RequestMethod[method];
|
|
173
177
|
const router = await applicationRef.createMiddlewareFactory(method);
|
|
174
178
|
const middlewareFunction = isMethodAll
|
|
175
179
|
? proxy
|
|
@@ -186,9 +190,9 @@ class MiddlewareModule {
|
|
|
186
190
|
pathsToApplyMiddleware.forEach(path => router(path, middlewareFunction));
|
|
187
191
|
}
|
|
188
192
|
getContextId(request, isTreeDurable) {
|
|
189
|
-
const contextId =
|
|
190
|
-
if (!request[
|
|
191
|
-
Object.defineProperty(request,
|
|
193
|
+
const contextId = ContextIdFactory.getByRequest(request);
|
|
194
|
+
if (!request[REQUEST_CONTEXT_ID]) {
|
|
195
|
+
Object.defineProperty(request, REQUEST_CONTEXT_ID, {
|
|
192
196
|
value: contextId,
|
|
193
197
|
enumerable: false,
|
|
194
198
|
writable: false,
|
|
@@ -202,4 +206,3 @@ class MiddlewareModule {
|
|
|
202
206
|
return contextId;
|
|
203
207
|
}
|
|
204
208
|
}
|
|
205
|
-
exports.MiddlewareModule = MiddlewareModule;
|
package/middleware/resolver.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Injector } from '../injector/injector';
|
|
2
|
-
import { Module } from '../injector/module';
|
|
3
|
-
import { MiddlewareContainer } from './container';
|
|
1
|
+
import { Injector } from '../injector/injector.js';
|
|
2
|
+
import { Module } from '../injector/module.js';
|
|
3
|
+
import { MiddlewareContainer } from './container.js';
|
|
4
4
|
export declare class MiddlewareResolver {
|
|
5
5
|
private readonly middlewareContainer;
|
|
6
6
|
private readonly injector;
|
package/middleware/resolver.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class MiddlewareResolver {
|
|
1
|
+
export class MiddlewareResolver {
|
|
2
|
+
middlewareContainer;
|
|
3
|
+
injector;
|
|
5
4
|
constructor(middlewareContainer, injector) {
|
|
6
5
|
this.middlewareContainer = middlewareContainer;
|
|
7
6
|
this.injector = injector;
|
|
@@ -15,4 +14,3 @@ class MiddlewareResolver {
|
|
|
15
14
|
await this.injector.loadMiddleware(wrapper, middlewareMap, moduleRef);
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
|
-
exports.MiddlewareResolver = MiddlewareResolver;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ApplicationConfig } from '../application-config.js';
|
|
2
|
+
import { type RouteInfo } from '@nestjs/common/internal';
|
|
3
3
|
export declare class RouteInfoPathExtractor {
|
|
4
4
|
private readonly applicationConfig;
|
|
5
5
|
private readonly routePathFactory;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { VersioningType } from '@nestjs/common';
|
|
2
|
+
import { isRouteExcluded } from '../router/utils/index.js';
|
|
3
|
+
import { RoutePathFactory } from './../router/route-path-factory.js';
|
|
4
|
+
import { addLeadingSlash, stripEndSlash, } from '@nestjs/common/internal';
|
|
5
|
+
export class RouteInfoPathExtractor {
|
|
6
|
+
applicationConfig;
|
|
7
|
+
routePathFactory;
|
|
8
|
+
prefixPath;
|
|
9
|
+
excludedGlobalPrefixRoutes;
|
|
10
|
+
versioningConfig;
|
|
9
11
|
constructor(applicationConfig) {
|
|
10
12
|
this.applicationConfig = applicationConfig;
|
|
11
|
-
this.routePathFactory = new
|
|
12
|
-
this.prefixPath =
|
|
13
|
+
this.routePathFactory = new RoutePathFactory(applicationConfig);
|
|
14
|
+
this.prefixPath = stripEndSlash(addLeadingSlash(this.applicationConfig.getGlobalPrefix()));
|
|
13
15
|
this.excludedGlobalPrefixRoutes =
|
|
14
16
|
this.applicationConfig.getGlobalPrefixOptions().exclude;
|
|
15
17
|
this.versioningConfig = this.applicationConfig.getVersioning();
|
|
@@ -21,19 +23,19 @@ class RouteInfoPathExtractor {
|
|
|
21
23
|
? versionPaths
|
|
22
24
|
.map(versionPath => [
|
|
23
25
|
this.prefixPath + versionPath + '$',
|
|
24
|
-
this.prefixPath + versionPath +
|
|
26
|
+
this.prefixPath + versionPath + addLeadingSlash(path),
|
|
25
27
|
])
|
|
26
28
|
.flat()
|
|
27
29
|
: this.prefixPath
|
|
28
|
-
? [this.prefixPath + '$', this.prefixPath +
|
|
29
|
-
: [
|
|
30
|
+
? [this.prefixPath + '$', this.prefixPath + addLeadingSlash(path)]
|
|
31
|
+
: [addLeadingSlash(path)];
|
|
30
32
|
return Array.isArray(this.excludedGlobalPrefixRoutes)
|
|
31
33
|
? [
|
|
32
34
|
...entries,
|
|
33
35
|
...this.excludedGlobalPrefixRoutes
|
|
34
36
|
.map(route => Array.isArray(versionPaths) && versionPaths.length > 0
|
|
35
|
-
? versionPaths.map(v => v +
|
|
36
|
-
:
|
|
37
|
+
? versionPaths.map(v => v + addLeadingSlash(route.path))
|
|
38
|
+
: addLeadingSlash(route.path))
|
|
37
39
|
.flat(),
|
|
38
40
|
]
|
|
39
41
|
: entries;
|
|
@@ -42,7 +44,7 @@ class RouteInfoPathExtractor {
|
|
|
42
44
|
}
|
|
43
45
|
extractPathFrom(route) {
|
|
44
46
|
if (this.isAWildcard(route.path) && !route.version) {
|
|
45
|
-
return [
|
|
47
|
+
return [addLeadingSlash(route.path)];
|
|
46
48
|
}
|
|
47
49
|
return this.extractNonWildcardPathsFrom(route);
|
|
48
50
|
}
|
|
@@ -57,25 +59,24 @@ class RouteInfoPathExtractor {
|
|
|
57
59
|
extractNonWildcardPathsFrom({ path, method, version, }) {
|
|
58
60
|
const versionPaths = this.extractVersionPathFrom(version);
|
|
59
61
|
if (Array.isArray(this.excludedGlobalPrefixRoutes) &&
|
|
60
|
-
|
|
62
|
+
isRouteExcluded(this.excludedGlobalPrefixRoutes, path, method)) {
|
|
61
63
|
if (!versionPaths.length) {
|
|
62
|
-
return [
|
|
64
|
+
return [addLeadingSlash(path)];
|
|
63
65
|
}
|
|
64
|
-
return versionPaths.map(versionPath => versionPath +
|
|
66
|
+
return versionPaths.map(versionPath => versionPath + addLeadingSlash(path));
|
|
65
67
|
}
|
|
66
68
|
if (!versionPaths.length) {
|
|
67
|
-
return [this.prefixPath +
|
|
69
|
+
return [this.prefixPath + addLeadingSlash(path)];
|
|
68
70
|
}
|
|
69
|
-
return versionPaths.map(versionPath => this.prefixPath + versionPath +
|
|
71
|
+
return versionPaths.map(versionPath => this.prefixPath + versionPath + addLeadingSlash(path));
|
|
70
72
|
}
|
|
71
73
|
extractVersionPathFrom(versionValue) {
|
|
72
|
-
if (!versionValue || this.versioningConfig?.type !==
|
|
74
|
+
if (!versionValue || this.versioningConfig?.type !== VersioningType.URI)
|
|
73
75
|
return [];
|
|
74
76
|
const versionPrefix = this.routePathFactory.getVersionPrefix(this.versioningConfig);
|
|
75
77
|
if (Array.isArray(versionValue)) {
|
|
76
|
-
return versionValue.map(version =>
|
|
78
|
+
return versionValue.map(version => addLeadingSlash(versionPrefix + version.toString()));
|
|
77
79
|
}
|
|
78
|
-
return [
|
|
80
|
+
return [addLeadingSlash(versionPrefix + versionValue.toString())];
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
|
-
exports.RouteInfoPathExtractor = RouteInfoPathExtractor;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ApplicationConfig } from '../application-config.js';
|
|
2
|
+
import { NestContainer } from '../injector/container.js';
|
|
3
|
+
import { type RouteInfo } from '@nestjs/common/internal';
|
|
4
|
+
import { type Type } from '@nestjs/common';
|
|
4
5
|
export declare class RoutesMapper {
|
|
5
6
|
private readonly container;
|
|
6
7
|
private readonly applicationConfig;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class RoutesMapper {
|
|
1
|
+
import { MetadataScanner } from '../metadata-scanner.js';
|
|
2
|
+
import { PathsExplorer } from '../router/paths-explorer.js';
|
|
3
|
+
import { targetModulesByContainer } from '../router/router-module.js';
|
|
4
|
+
import { MODULE_PATH, PATH_METADATA, VERSION_METADATA, addLeadingSlash, isString, isUndefined, } from '@nestjs/common/internal';
|
|
5
|
+
import { VERSION_NEUTRAL } from '@nestjs/common';
|
|
6
|
+
export class RoutesMapper {
|
|
7
|
+
container;
|
|
8
|
+
applicationConfig;
|
|
9
|
+
pathsExplorer;
|
|
11
10
|
constructor(container, applicationConfig) {
|
|
12
11
|
this.container = container;
|
|
13
12
|
this.applicationConfig = applicationConfig;
|
|
14
|
-
this.pathsExplorer = new
|
|
13
|
+
this.pathsExplorer = new PathsExplorer(new MetadataScanner());
|
|
15
14
|
}
|
|
16
15
|
mapRouteToRouteInfo(controllerOrRoute) {
|
|
17
|
-
if (
|
|
16
|
+
if (isString(controllerOrRoute)) {
|
|
18
17
|
return this.getRouteInfoFromPath(controllerOrRoute);
|
|
19
18
|
}
|
|
20
19
|
const routePathOrPaths = this.getRoutePath(controllerOrRoute);
|
|
@@ -27,14 +26,14 @@ class RoutesMapper {
|
|
|
27
26
|
const defaultRequestMethod = -1;
|
|
28
27
|
return [
|
|
29
28
|
{
|
|
30
|
-
path:
|
|
29
|
+
path: addLeadingSlash(routePath),
|
|
31
30
|
method: defaultRequestMethod,
|
|
32
31
|
},
|
|
33
32
|
];
|
|
34
33
|
}
|
|
35
34
|
getRouteInfoFromObject(routeInfoObject) {
|
|
36
35
|
const routeInfo = {
|
|
37
|
-
path:
|
|
36
|
+
path: addLeadingSlash(routeInfoObject.path),
|
|
38
37
|
method: routeInfoObject.method,
|
|
39
38
|
};
|
|
40
39
|
if (routeInfoObject.version) {
|
|
@@ -49,10 +48,10 @@ class RoutesMapper {
|
|
|
49
48
|
const moduleRef = this.getHostModuleOfController(controller);
|
|
50
49
|
const modulePath = this.getModulePath(moduleRef?.metatype);
|
|
51
50
|
const concatPaths = (acc, currentValue) => acc.concat(currentValue);
|
|
52
|
-
const toUndefinedIfNeural = (version) => version ===
|
|
51
|
+
const toUndefinedIfNeural = (version) => version === VERSION_NEUTRAL ? undefined : version;
|
|
53
52
|
const toRouteInfo = (item, prefix) => item.path?.flatMap(p => {
|
|
54
53
|
let endpointPath = modulePath ?? '';
|
|
55
|
-
endpointPath += this.normalizeGlobalPath(prefix) +
|
|
54
|
+
endpointPath += this.normalizeGlobalPath(prefix) + addLeadingSlash(p);
|
|
56
55
|
const routeInfo = {
|
|
57
56
|
path: endpointPath,
|
|
58
57
|
method: item.requestMethod,
|
|
@@ -77,21 +76,21 @@ class RoutesMapper {
|
|
|
77
76
|
.reduce(concatPaths, []);
|
|
78
77
|
}
|
|
79
78
|
isRouteInfo(path, objectOrClass) {
|
|
80
|
-
return
|
|
79
|
+
return isUndefined(path);
|
|
81
80
|
}
|
|
82
81
|
normalizeGlobalPath(path) {
|
|
83
|
-
const prefix =
|
|
82
|
+
const prefix = addLeadingSlash(path);
|
|
84
83
|
return prefix === '/' ? '' : prefix;
|
|
85
84
|
}
|
|
86
85
|
getRoutePath(route) {
|
|
87
|
-
return Reflect.getMetadata(
|
|
86
|
+
return Reflect.getMetadata(PATH_METADATA, route);
|
|
88
87
|
}
|
|
89
88
|
getHostModuleOfController(metatype) {
|
|
90
89
|
if (!metatype) {
|
|
91
90
|
return;
|
|
92
91
|
}
|
|
93
92
|
const modulesContainer = this.container.getModules();
|
|
94
|
-
const moduleRefsSet =
|
|
93
|
+
const moduleRefsSet = targetModulesByContainer.get(modulesContainer);
|
|
95
94
|
if (!moduleRefsSet) {
|
|
96
95
|
return;
|
|
97
96
|
}
|
|
@@ -103,15 +102,14 @@ class RoutesMapper {
|
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
105
104
|
const modulesContainer = this.container.getModules();
|
|
106
|
-
const modulePath = Reflect.getMetadata(
|
|
107
|
-
return modulePath ?? Reflect.getMetadata(
|
|
105
|
+
const modulePath = Reflect.getMetadata(MODULE_PATH + modulesContainer.applicationId, metatype);
|
|
106
|
+
return modulePath ?? Reflect.getMetadata(MODULE_PATH, metatype);
|
|
108
107
|
}
|
|
109
108
|
getVersionMetadata(metatype) {
|
|
110
109
|
const versioningConfig = this.applicationConfig.getVersioning();
|
|
111
110
|
if (versioningConfig) {
|
|
112
|
-
return (Reflect.getMetadata(
|
|
111
|
+
return (Reflect.getMetadata(VERSION_METADATA, metatype) ??
|
|
113
112
|
versioningConfig.defaultVersion);
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
|
-
exports.RoutesMapper = RoutesMapper;
|
package/middleware/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ExcludeRouteMetadata } from '../router/interfaces/exclude-route-metadata.interface.js';
|
|
2
|
+
import type { HttpServer, Type } from '@nestjs/common';
|
|
3
|
+
import { type RouteInfo } from '@nestjs/common/internal';
|
|
3
4
|
export declare const mapToExcludeRoute: (routes: (string | RouteInfo)[]) => ExcludeRouteMetadata[];
|
|
4
5
|
export declare const filterMiddleware: <T extends Function | Type<any> = any>(middleware: T[], routes: RouteInfo[], httpAdapter: HttpServer) => Type<any>[];
|
|
5
6
|
export declare const mapToClass: <T extends Function | Type<any>>(middleware: T, excludedRoutes: ExcludeRouteMetadata[], httpAdapter: HttpServer) => Type<any>;
|
package/middleware/utils.js
CHANGED
|
@@ -1,53 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
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) => {
|
|
1
|
+
import { RequestMethod } from '@nestjs/common';
|
|
2
|
+
import { iterate } from 'iterare';
|
|
3
|
+
import { pathToRegexp } from 'path-to-regexp';
|
|
4
|
+
import { uid } from 'uid';
|
|
5
|
+
import { LegacyRouteConverter } from '../router/legacy-route-converter.js';
|
|
6
|
+
import { isRouteExcluded } from '../router/utils/index.js';
|
|
7
|
+
import { addLeadingSlash, isFunction, isString, } from '@nestjs/common/internal';
|
|
8
|
+
export const mapToExcludeRoute = (routes) => {
|
|
15
9
|
return routes.map(route => {
|
|
16
|
-
const originalPath =
|
|
17
|
-
const path =
|
|
10
|
+
const originalPath = isString(route) ? route : route.path;
|
|
11
|
+
const path = LegacyRouteConverter.tryConvert(originalPath);
|
|
18
12
|
try {
|
|
19
|
-
if (
|
|
13
|
+
if (isString(route)) {
|
|
20
14
|
return {
|
|
21
15
|
path,
|
|
22
|
-
requestMethod:
|
|
23
|
-
pathRegex:
|
|
16
|
+
requestMethod: RequestMethod.ALL,
|
|
17
|
+
pathRegex: pathToRegexp(addLeadingSlash(path)).regexp,
|
|
24
18
|
};
|
|
25
19
|
}
|
|
26
20
|
return {
|
|
27
21
|
path,
|
|
28
22
|
requestMethod: route.method,
|
|
29
|
-
pathRegex:
|
|
23
|
+
pathRegex: pathToRegexp(addLeadingSlash(path)).regexp,
|
|
30
24
|
};
|
|
31
25
|
}
|
|
32
26
|
catch (e) {
|
|
33
27
|
if (e instanceof TypeError) {
|
|
34
|
-
|
|
28
|
+
LegacyRouteConverter.printError(originalPath);
|
|
35
29
|
}
|
|
36
30
|
throw e;
|
|
37
31
|
}
|
|
38
32
|
});
|
|
39
33
|
};
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
return (0, iterare_1.iterate)([])
|
|
34
|
+
export const filterMiddleware = (middleware, routes, httpAdapter) => {
|
|
35
|
+
const excludedRoutes = mapToExcludeRoute(routes);
|
|
36
|
+
return iterate([])
|
|
44
37
|
.concat(middleware)
|
|
45
|
-
.filter(
|
|
46
|
-
.map((item) =>
|
|
38
|
+
.filter(isFunction)
|
|
39
|
+
.map((item) => mapToClass(item, excludedRoutes, httpAdapter))
|
|
47
40
|
.toArray();
|
|
48
41
|
};
|
|
49
|
-
|
|
50
|
-
const mapToClass = (middleware, excludedRoutes, httpAdapter) => {
|
|
42
|
+
export const mapToClass = (middleware, excludedRoutes, httpAdapter) => {
|
|
51
43
|
if (isMiddlewareClass(middleware)) {
|
|
52
44
|
if (excludedRoutes.length <= 0) {
|
|
53
45
|
return middleware;
|
|
@@ -65,20 +57,17 @@ const mapToClass = (middleware, excludedRoutes, httpAdapter) => {
|
|
|
65
57
|
return assignToken(MiddlewareHost, middleware.name);
|
|
66
58
|
}
|
|
67
59
|
return assignToken(class {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
}
|
|
60
|
+
use = (...params) => {
|
|
61
|
+
const [req, _, next] = params;
|
|
62
|
+
const isExcluded = isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter);
|
|
63
|
+
if (isExcluded) {
|
|
64
|
+
return next();
|
|
65
|
+
}
|
|
66
|
+
return middleware(...params);
|
|
67
|
+
};
|
|
78
68
|
});
|
|
79
69
|
};
|
|
80
|
-
|
|
81
|
-
function isMiddlewareClass(middleware) {
|
|
70
|
+
export function isMiddlewareClass(middleware) {
|
|
82
71
|
const middlewareStr = middleware.toString();
|
|
83
72
|
if (middlewareStr.substring(0, 5) === 'class') {
|
|
84
73
|
return true;
|
|
@@ -86,13 +75,13 @@ function isMiddlewareClass(middleware) {
|
|
|
86
75
|
const middlewareArr = middlewareStr.split(' ');
|
|
87
76
|
return (middlewareArr[0] === 'function' &&
|
|
88
77
|
/[A-Z]/.test(middlewareArr[1]?.[0]) &&
|
|
89
|
-
|
|
78
|
+
isFunction(middleware.prototype?.use));
|
|
90
79
|
}
|
|
91
|
-
function assignToken(metatype, token =
|
|
80
|
+
export function assignToken(metatype, token = uid(21)) {
|
|
92
81
|
Object.defineProperty(metatype, 'name', { value: token });
|
|
93
82
|
return metatype;
|
|
94
83
|
}
|
|
95
|
-
function isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter) {
|
|
84
|
+
export function isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter) {
|
|
96
85
|
if (excludedRoutes.length <= 0) {
|
|
97
86
|
return false;
|
|
98
87
|
}
|
|
@@ -102,5 +91,5 @@ function isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter) {
|
|
|
102
91
|
const pathname = queryParamsIndex >= 0
|
|
103
92
|
? originalUrl.slice(0, queryParamsIndex)
|
|
104
93
|
: originalUrl;
|
|
105
|
-
return
|
|
94
|
+
return isRouteExcluded(excludedRoutes, pathname, RequestMethod[reqMethod]);
|
|
106
95
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { INestApplicationContext, Logger, LoggerService, LogLevel, ShutdownSignal } from '@nestjs/common';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { type INestApplicationContext, Logger, type LoggerService, type LogLevel, ShutdownSignal } from '@nestjs/common';
|
|
2
|
+
import { AbstractInstanceResolver } from './injector/abstract-instance-resolver.js';
|
|
3
|
+
import { NestContainer } from './injector/container.js';
|
|
4
|
+
import { Injector } from './injector/injector.js';
|
|
5
|
+
import { InstanceLinksHost } from './injector/instance-links-host.js';
|
|
6
|
+
import { ContextId } from './injector/instance-wrapper.js';
|
|
7
|
+
import { Module } from './injector/module.js';
|
|
8
|
+
import type { DynamicModule, Type } from '@nestjs/common';
|
|
9
|
+
import { type SelectOptions, type ShutdownHooksOptions, type NestApplicationContextOptions } from '@nestjs/common/internal';
|
|
10
10
|
/**
|
|
11
11
|
* @publicApi
|
|
12
12
|
*/
|
|
@@ -129,6 +129,7 @@ export declare class NestApplicationContext<TOptions extends NestApplicationCont
|
|
|
129
129
|
* @returns {this} The Nest application context instance
|
|
130
130
|
*/
|
|
131
131
|
enableShutdownHooks(signals?: (ShutdownSignal | string)[], options?: ShutdownHooksOptions): this;
|
|
132
|
+
protected prepareClose(): Promise<void>;
|
|
132
133
|
protected dispose(): Promise<void>;
|
|
133
134
|
/**
|
|
134
135
|
* Listens to shutdown signals by listening to
|