@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,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RuntimeException = void 0;
|
|
4
|
-
class RuntimeException extends Error {
|
|
1
|
+
export class RuntimeException extends Error {
|
|
5
2
|
constructor(message = ``) {
|
|
6
3
|
super(message);
|
|
7
4
|
}
|
|
@@ -9,4 +6,3 @@ class RuntimeException extends Error {
|
|
|
9
6
|
return this.message;
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.RuntimeException = RuntimeException;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InjectorDependencyContext } from '../../injector/injector';
|
|
2
|
-
import { Module } from '../../injector/module';
|
|
3
|
-
import { RuntimeException } from './runtime.exception';
|
|
1
|
+
import { InjectorDependencyContext } from '../../injector/injector.js';
|
|
2
|
+
import { Module } from '../../injector/module.js';
|
|
3
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
4
4
|
export declare class UndefinedDependencyException extends RuntimeException {
|
|
5
5
|
constructor(type: string, undefinedDependencyContext: InjectorDependencyContext, moduleRef?: Module);
|
|
6
6
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const messages_1 = require("../messages");
|
|
5
|
-
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
-
class UndefinedDependencyException extends runtime_exception_1.RuntimeException {
|
|
1
|
+
import { UNKNOWN_DEPENDENCIES_MESSAGE } from '../messages.js';
|
|
2
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
3
|
+
export class UndefinedDependencyException extends RuntimeException {
|
|
7
4
|
constructor(type, undefinedDependencyContext, moduleRef) {
|
|
8
|
-
super(
|
|
5
|
+
super(UNKNOWN_DEPENDENCIES_MESSAGE(type, undefinedDependencyContext, moduleRef));
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.UndefinedDependencyException = UndefinedDependencyException;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RuntimeException } from './runtime.exception';
|
|
2
|
-
import { Type } from '@nestjs/common';
|
|
1
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
2
|
+
import type { Type } from '@nestjs/common';
|
|
3
3
|
export declare class UndefinedForwardRefException extends RuntimeException {
|
|
4
4
|
constructor(scope: Type<any>[]);
|
|
5
5
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const messages_1 = require("../messages");
|
|
5
|
-
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
-
class UndefinedForwardRefException extends runtime_exception_1.RuntimeException {
|
|
1
|
+
import { UNDEFINED_FORWARDREF_MESSAGE } from '../messages.js';
|
|
2
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
3
|
+
export class UndefinedForwardRefException extends RuntimeException {
|
|
7
4
|
constructor(scope) {
|
|
8
|
-
super(
|
|
5
|
+
super(UNDEFINED_FORWARDREF_MESSAGE(scope));
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.UndefinedForwardRefException = UndefinedForwardRefException;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const runtime_exception_1 = require("./runtime.exception");
|
|
5
|
-
const messages_1 = require("../messages");
|
|
6
|
-
class UndefinedModuleException extends runtime_exception_1.RuntimeException {
|
|
1
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
2
|
+
import { UNDEFINED_MODULE_MESSAGE } from '../messages.js';
|
|
3
|
+
export class UndefinedModuleException extends RuntimeException {
|
|
7
4
|
constructor(parentModule, index, scope) {
|
|
8
|
-
super(
|
|
5
|
+
super(UNDEFINED_MODULE_MESSAGE(parentModule, index, scope));
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.UndefinedModuleException = UndefinedModuleException;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InjectorDependencyContext } from '../../injector/injector';
|
|
2
|
-
import { Module } from '../../injector/module';
|
|
3
|
-
import { RuntimeException } from './runtime.exception';
|
|
1
|
+
import { InjectorDependencyContext } from '../../injector/injector.js';
|
|
2
|
+
import { Module } from '../../injector/module.js';
|
|
3
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
4
4
|
export declare class UnknownDependenciesException extends RuntimeException {
|
|
5
5
|
readonly type: string | symbol;
|
|
6
6
|
readonly context: InjectorDependencyContext;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { UNKNOWN_DEPENDENCIES_MESSAGE } from '../messages.js';
|
|
2
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
3
|
+
export class UnknownDependenciesException extends RuntimeException {
|
|
4
|
+
type;
|
|
5
|
+
context;
|
|
6
|
+
metadata;
|
|
7
|
+
moduleRef;
|
|
7
8
|
constructor(type, context, moduleRef, metadata) {
|
|
8
|
-
super(
|
|
9
|
+
super(UNKNOWN_DEPENDENCIES_MESSAGE(type, context, moduleRef));
|
|
9
10
|
this.type = type;
|
|
10
11
|
this.context = context;
|
|
11
12
|
this.metadata = metadata;
|
|
12
13
|
this.moduleRef = moduleRef && { id: moduleRef.id };
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
exports.UnknownDependenciesException = UnknownDependenciesException;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.UnknownElementException = void 0;
|
|
4
|
-
const runtime_exception_1 = require("./runtime.exception");
|
|
5
|
-
class UnknownElementException extends runtime_exception_1.RuntimeException {
|
|
1
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
2
|
+
export class UnknownElementException extends RuntimeException {
|
|
6
3
|
constructor(name) {
|
|
7
4
|
name = name && name.toString();
|
|
8
5
|
super(`Nest could not find ${name || 'given'} element (this provider does not exist in the current context)`);
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.UnknownElementException = UnknownElementException;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const messages_1 = require("../messages");
|
|
5
|
-
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
-
class UnknownExportException extends runtime_exception_1.RuntimeException {
|
|
1
|
+
import { UNKNOWN_EXPORT_MESSAGE } from '../messages.js';
|
|
2
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
3
|
+
export class UnknownExportException extends RuntimeException {
|
|
7
4
|
constructor(token, moduleName) {
|
|
8
|
-
super(
|
|
5
|
+
super(UNKNOWN_EXPORT_MESSAGE(token, moduleName));
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.UnknownExportException = UnknownExportException;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.UnknownModuleException = void 0;
|
|
4
|
-
const runtime_exception_1 = require("./runtime.exception");
|
|
5
|
-
class UnknownModuleException extends runtime_exception_1.RuntimeException {
|
|
1
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
2
|
+
export class UnknownModuleException extends RuntimeException {
|
|
6
3
|
constructor(moduleName) {
|
|
7
4
|
super(`Nest could not select the given module (${moduleName ? `"${moduleName}"` : 'it'} does not exist in current context).`);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
exports.UnknownModuleException = UnknownModuleException;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Type } from '@nestjs/common';
|
|
2
|
-
import { RuntimeException } from './runtime.exception';
|
|
2
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
3
3
|
export declare class UnknownRequestMappingException extends RuntimeException {
|
|
4
4
|
constructor(metatype: Type);
|
|
5
5
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const runtime_exception_1 = require("./runtime.exception");
|
|
5
|
-
const messages_1 = require("../messages");
|
|
6
|
-
class UnknownRequestMappingException extends runtime_exception_1.RuntimeException {
|
|
1
|
+
import { RuntimeException } from './runtime.exception.js';
|
|
2
|
+
import { UNKNOWN_REQUEST_MAPPING } from '../messages.js';
|
|
3
|
+
export class UnknownRequestMappingException extends RuntimeException {
|
|
7
4
|
constructor(metatype) {
|
|
8
|
-
super(
|
|
5
|
+
super(UNKNOWN_REQUEST_MAPPING(metatype));
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.UnknownRequestMappingException = UnknownRequestMappingException;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ExceptionsZone = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const exception_handler_1 = require("./exception-handler");
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { ExceptionHandler } from './exception-handler.js';
|
|
6
3
|
const DEFAULT_TEARDOWN = () => process.exit(1);
|
|
7
|
-
class ExceptionsZone {
|
|
4
|
+
export class ExceptionsZone {
|
|
5
|
+
static exceptionHandler = new ExceptionHandler();
|
|
8
6
|
static run(callback, teardown = DEFAULT_TEARDOWN, autoFlushLogs) {
|
|
9
7
|
try {
|
|
10
8
|
callback();
|
|
@@ -12,7 +10,7 @@ class ExceptionsZone {
|
|
|
12
10
|
catch (e) {
|
|
13
11
|
this.exceptionHandler.handle(e);
|
|
14
12
|
if (autoFlushLogs) {
|
|
15
|
-
|
|
13
|
+
Logger.flush();
|
|
16
14
|
}
|
|
17
15
|
teardown(e);
|
|
18
16
|
}
|
|
@@ -24,11 +22,9 @@ class ExceptionsZone {
|
|
|
24
22
|
catch (e) {
|
|
25
23
|
this.exceptionHandler.handle(e);
|
|
26
24
|
if (autoFlushLogs) {
|
|
27
|
-
|
|
25
|
+
Logger.flush();
|
|
28
26
|
}
|
|
29
27
|
teardown(e);
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
|
-
exports.ExceptionsZone = ExceptionsZone;
|
|
34
|
-
ExceptionsZone.exceptionHandler = new exception_handler_1.ExceptionHandler();
|
package/errors/messages.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ForwardReference, Type } from '@nestjs/common';
|
|
2
|
-
import { InjectorDependencyContext } from '../injector/injector';
|
|
3
|
-
import { Module } from '../injector/module';
|
|
2
|
+
import { InjectorDependencyContext } from '../injector/injector.js';
|
|
3
|
+
import { Module } from '../injector/module.js';
|
|
4
4
|
export declare const UNKNOWN_DEPENDENCIES_MESSAGE: (type: string | symbol, unknownDependencyContext: InjectorDependencyContext, moduleRef: Module | undefined) => string;
|
|
5
5
|
export declare const INVALID_MIDDLEWARE_MESSAGE: (text: TemplateStringsArray, name: string) => string;
|
|
6
6
|
export declare const UNDEFINED_FORWARDREF_MESSAGE: (scope: Type<any>[]) => string;
|
package/errors/messages.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = exports.INVALID_EXCEPTION_FILTER = exports.UNHANDLED_RUNTIME_EXCEPTION = exports.INVALID_MIDDLEWARE_CONFIGURATION = exports.UNKNOWN_REQUEST_MAPPING = exports.INVALID_CLASS_SCOPE_MESSAGE = exports.INVALID_CLASS_MESSAGE = exports.UNKNOWN_EXPORT_MESSAGE = exports.UNDEFINED_MODULE_MESSAGE = exports.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = exports.INVALID_MODULE_MESSAGE = exports.UNDEFINED_FORWARDREF_MESSAGE = exports.INVALID_MIDDLEWARE_MESSAGE = exports.UNKNOWN_DEPENDENCIES_MESSAGE = void 0;
|
|
4
|
-
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
1
|
+
import { isNil, isSymbol } from '@nestjs/common/internal';
|
|
5
2
|
/**
|
|
6
3
|
* Returns the name of an instance or `undefined`
|
|
7
4
|
* @param instance The instance which should get the name from
|
|
@@ -28,7 +25,7 @@ const getDependencyName = (dependency, fallbackValue, disambiguated = true) =>
|
|
|
28
25
|
// use class name
|
|
29
26
|
getInstanceName(dependency) ||
|
|
30
27
|
// use injection token (symbol)
|
|
31
|
-
(
|
|
28
|
+
(isSymbol(dependency) && dependency.toString()) ||
|
|
32
29
|
// use string directly
|
|
33
30
|
(dependency
|
|
34
31
|
? disambiguated
|
|
@@ -44,11 +41,11 @@ getInstanceName(dependency) ||
|
|
|
44
41
|
*/
|
|
45
42
|
const getModuleName = (module) => (module && getInstanceName(module.metatype)) || 'current';
|
|
46
43
|
const stringifyScope = (scope) => (scope || []).map(getInstanceName).join(' -> ');
|
|
47
|
-
const UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext, moduleRef) => {
|
|
44
|
+
export const UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext, moduleRef) => {
|
|
48
45
|
const { index, name, dependencies, key } = unknownDependencyContext;
|
|
49
46
|
const moduleName = getModuleName(moduleRef);
|
|
50
47
|
const dependencyName = getDependencyName(name, 'dependency');
|
|
51
|
-
const isImportTypeIssue = !
|
|
48
|
+
const isImportTypeIssue = !isNil(index) &&
|
|
52
49
|
dependencies &&
|
|
53
50
|
(dependencies[index] === undefined ||
|
|
54
51
|
dependencies[index] === Object ||
|
|
@@ -93,7 +90,7 @@ Potential solutions:
|
|
|
93
90
|
For more common dependency resolution issues, see: https://docs.nestjs.com/faq/common-errors`;
|
|
94
91
|
}
|
|
95
92
|
let message = `Nest can't resolve dependencies of the ${type.toString()}`;
|
|
96
|
-
if (
|
|
93
|
+
if (isNil(index)) {
|
|
97
94
|
message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
|
|
98
95
|
return message;
|
|
99
96
|
}
|
|
@@ -105,24 +102,20 @@ For more common dependency resolution issues, see: https://docs.nestjs.com/faq/c
|
|
|
105
102
|
message += potentialSolutions;
|
|
106
103
|
return message;
|
|
107
104
|
};
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
exports.INVALID_MIDDLEWARE_MESSAGE = INVALID_MIDDLEWARE_MESSAGE;
|
|
111
|
-
const UNDEFINED_FORWARDREF_MESSAGE = (scope) => `Nest cannot create the module instance. Often, this is because of a circular dependency between modules. Use forwardRef() to avoid it.
|
|
105
|
+
export const INVALID_MIDDLEWARE_MESSAGE = (text, name) => `The middleware doesn't provide the 'use' method (${name})`;
|
|
106
|
+
export const UNDEFINED_FORWARDREF_MESSAGE = (scope) => `Nest cannot create the module instance. Often, this is because of a circular dependency between modules. Use forwardRef() to avoid it.
|
|
112
107
|
|
|
113
108
|
(Read more: https://docs.nestjs.com/fundamentals/circular-dependency)
|
|
114
109
|
Scope [${stringifyScope(scope)}]
|
|
115
110
|
`;
|
|
116
|
-
|
|
117
|
-
const INVALID_MODULE_MESSAGE = (parentModule, index, scope) => {
|
|
111
|
+
export const INVALID_MODULE_MESSAGE = (parentModule, index, scope) => {
|
|
118
112
|
const parentModuleName = parentModule?.name || 'module';
|
|
119
113
|
return `Nest cannot create the ${parentModuleName} instance.
|
|
120
114
|
Received an unexpected value at index [${index}] of the ${parentModuleName} "imports" array.
|
|
121
115
|
|
|
122
116
|
Scope [${stringifyScope(scope)}]`;
|
|
123
117
|
};
|
|
124
|
-
|
|
125
|
-
const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = (metatypeUsedAsAModule, scope) => {
|
|
118
|
+
export const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = (metatypeUsedAsAModule, scope) => {
|
|
126
119
|
const metatypeNameQuote = `"${getInstanceName(metatypeUsedAsAModule)}"`;
|
|
127
120
|
return `Classes annotated with @Injectable(), @Catch(), and @Controller() decorators must not appear in the "imports" array of a module.
|
|
128
121
|
Please remove ${metatypeNameQuote} (including forwarded occurrences, if any) from all of the "imports" arrays.
|
|
@@ -130,8 +123,7 @@ Please remove ${metatypeNameQuote} (including forwarded occurrences, if any) fro
|
|
|
130
123
|
Scope [${stringifyScope(scope)}]
|
|
131
124
|
`;
|
|
132
125
|
};
|
|
133
|
-
|
|
134
|
-
const UNDEFINED_MODULE_MESSAGE = (parentModule, index, scope) => {
|
|
126
|
+
export const UNDEFINED_MODULE_MESSAGE = (parentModule, index, scope) => {
|
|
135
127
|
const parentModuleName = parentModule?.name || 'module';
|
|
136
128
|
return `Nest cannot create the ${parentModuleName} instance.
|
|
137
129
|
The module at index [${index}] of the ${parentModuleName} "imports" array is undefined.
|
|
@@ -142,9 +134,8 @@ Potential causes:
|
|
|
142
134
|
|
|
143
135
|
Scope [${stringifyScope(scope)}]`;
|
|
144
136
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
token = (0, shared_utils_1.isSymbol)(token) ? token.toString() : token;
|
|
137
|
+
export const UNKNOWN_EXPORT_MESSAGE = (token = 'item', module) => {
|
|
138
|
+
token = isSymbol(token) ? token.toString() : token;
|
|
148
139
|
return `Nest cannot export a provider/module that is not a part of the currently processed module (${module}). Please verify whether the exported ${token} is available in this particular context.
|
|
149
140
|
|
|
150
141
|
Possible Solutions:
|
|
@@ -153,19 +144,15 @@ Possible Solutions:
|
|
|
153
144
|
For more common dependency resolution issues, see: https://docs.nestjs.com/faq/common-errors
|
|
154
145
|
`;
|
|
155
146
|
};
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const INVALID_CLASS_SCOPE_MESSAGE = (text, name) => `${name || 'This class'} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
|
|
160
|
-
exports.INVALID_CLASS_SCOPE_MESSAGE = INVALID_CLASS_SCOPE_MESSAGE;
|
|
161
|
-
const UNKNOWN_REQUEST_MAPPING = (metatype) => {
|
|
147
|
+
export const INVALID_CLASS_MESSAGE = (text, value) => `ModuleRef cannot instantiate class (${value} is not constructable).`;
|
|
148
|
+
export const INVALID_CLASS_SCOPE_MESSAGE = (text, name) => `${name || 'This class'} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
|
|
149
|
+
export const UNKNOWN_REQUEST_MAPPING = (metatype) => {
|
|
162
150
|
const className = metatype.name;
|
|
163
151
|
return className
|
|
164
152
|
? `An invalid controller has been detected. "${className}" does not have the @Controller() decorator but it is being listed in the "controllers" array of some module.`
|
|
165
153
|
: `An invalid controller has been detected. Perhaps, one of your controllers is missing the @Controller() decorator.`;
|
|
166
154
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = `Unable to load @nestjs/microservices package. (Please make sure that it's already installed.)`;
|
|
155
|
+
export const INVALID_MIDDLEWARE_CONFIGURATION = `An invalid middleware configuration has been passed inside the module 'configure()' method.`;
|
|
156
|
+
export const UNHANDLED_RUNTIME_EXCEPTION = `Unhandled Runtime Exception.`;
|
|
157
|
+
export const INVALID_EXCEPTION_FILTER = `Invalid exception filters (@UseFilters()).`;
|
|
158
|
+
export const MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = `Unable to load @nestjs/microservices package. (Please make sure that it's already installed.)`;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { InstanceWrapper } from '../injector/instance-wrapper';
|
|
1
|
+
import { ContextCreator } from '../helpers/context-creator.js';
|
|
2
|
+
import { NestContainer } from '../injector/container.js';
|
|
3
|
+
import { InstanceWrapper } from '../injector/instance-wrapper.js';
|
|
4
|
+
import type { Type, ExceptionFilter } from '@nestjs/common';
|
|
6
5
|
export declare class BaseExceptionFilterContext extends ContextCreator {
|
|
7
6
|
private readonly container;
|
|
8
7
|
protected moduleContext: string;
|
|
9
8
|
constructor(container: NestContainer);
|
|
10
|
-
createConcreteContext<T extends any[], R extends any[]>(metadata: T, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): R;
|
|
11
|
-
getFilterInstance(filter: Function | ExceptionFilter, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): ExceptionFilter | null;
|
|
9
|
+
createConcreteContext<T extends any[], R extends any[]>(metadata: T, contextId?: import("../injector/instance-wrapper.js").ContextId, inquirerId?: string): R;
|
|
10
|
+
getFilterInstance(filter: Function | ExceptionFilter, contextId?: import("../injector/instance-wrapper.js").ContextId, inquirerId?: string): ExceptionFilter | null;
|
|
12
11
|
getInstanceByMetatype(metatype: Type<unknown>): InstanceWrapper | undefined;
|
|
13
12
|
reflectCatchExceptions(instance: ExceptionFilter): Type<any>[];
|
|
14
13
|
}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const constants_2 = require("../injector/constants");
|
|
9
|
-
class BaseExceptionFilterContext extends context_creator_1.ContextCreator {
|
|
1
|
+
import { iterate } from 'iterare';
|
|
2
|
+
import { ContextCreator } from '../helpers/context-creator.js';
|
|
3
|
+
import { STATIC_CONTEXT } from '../injector/constants.js';
|
|
4
|
+
import { FILTER_CATCH_EXCEPTIONS, isEmpty, isFunction, } from '@nestjs/common/internal';
|
|
5
|
+
export class BaseExceptionFilterContext extends ContextCreator {
|
|
6
|
+
container;
|
|
7
|
+
moduleContext;
|
|
10
8
|
constructor(container) {
|
|
11
9
|
super();
|
|
12
10
|
this.container = container;
|
|
13
11
|
}
|
|
14
|
-
createConcreteContext(metadata, contextId =
|
|
15
|
-
if (
|
|
12
|
+
createConcreteContext(metadata, contextId = STATIC_CONTEXT, inquirerId) {
|
|
13
|
+
if (isEmpty(metadata)) {
|
|
16
14
|
return [];
|
|
17
15
|
}
|
|
18
|
-
return
|
|
19
|
-
.filter(instance => instance && (
|
|
16
|
+
return iterate(metadata)
|
|
17
|
+
.filter(instance => instance && (isFunction(instance.catch) || instance.name))
|
|
20
18
|
.map(filter => this.getFilterInstance(filter, contextId, inquirerId))
|
|
21
19
|
.filter(item => !!item)
|
|
22
20
|
.map(instance => ({
|
|
@@ -25,7 +23,7 @@ class BaseExceptionFilterContext extends context_creator_1.ContextCreator {
|
|
|
25
23
|
}))
|
|
26
24
|
.toArray();
|
|
27
25
|
}
|
|
28
|
-
getFilterInstance(filter, contextId =
|
|
26
|
+
getFilterInstance(filter, contextId = STATIC_CONTEXT, inquirerId) {
|
|
29
27
|
const isObject = !!filter.catch;
|
|
30
28
|
if (isObject) {
|
|
31
29
|
return filter;
|
|
@@ -50,7 +48,6 @@ class BaseExceptionFilterContext extends context_creator_1.ContextCreator {
|
|
|
50
48
|
}
|
|
51
49
|
reflectCatchExceptions(instance) {
|
|
52
50
|
const prototype = Object.getPrototypeOf(instance);
|
|
53
|
-
return (Reflect.getMetadata(
|
|
51
|
+
return (Reflect.getMetadata(FILTER_CATCH_EXCEPTIONS, prototype.constructor) || []);
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
|
-
exports.BaseExceptionFilterContext = BaseExceptionFilterContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ArgumentsHost, ExceptionFilter, HttpServer } from '@nestjs/common';
|
|
2
|
-
import { AbstractHttpAdapter } from '../adapters';
|
|
3
|
-
import { HttpAdapterHost } from '../helpers/http-adapter-host';
|
|
1
|
+
import { type ArgumentsHost, type ExceptionFilter, type HttpServer } from '@nestjs/common';
|
|
2
|
+
import { AbstractHttpAdapter } from '../adapters/index.js';
|
|
3
|
+
import { HttpAdapterHost } from '../helpers/http-adapter-host.js';
|
|
4
4
|
export declare class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
|
|
5
5
|
protected readonly applicationRef?: HttpServer | undefined;
|
|
6
6
|
private static readonly logger;
|
|
@@ -10,7 +10,7 @@ export declare class BaseExceptionFilter<T = any> implements ExceptionFilter<T>
|
|
|
10
10
|
handleUnknownError(exception: T, host: ArgumentsHost, applicationRef: AbstractHttpAdapter | HttpServer): void;
|
|
11
11
|
isExceptionObject(err: any): err is Error;
|
|
12
12
|
/**
|
|
13
|
-
* Checks if the thrown error comes from the "http-errors" library.
|
|
13
|
+
* Checks if the thrown error is a FastifyError or comes from the "http-errors" library.
|
|
14
14
|
* @param err error object
|
|
15
15
|
*/
|
|
16
16
|
isHttpError(err: any): err is {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { HttpException, HttpStatus, Inject, IntrinsicException, Logger, Optional, } from '@nestjs/common';
|
|
3
|
+
import { MESSAGES } from '../constants.js';
|
|
4
|
+
import { HttpAdapterHost } from '../helpers/http-adapter-host.js';
|
|
5
|
+
import { isObject } from '@nestjs/common/internal';
|
|
6
|
+
export class BaseExceptionFilter {
|
|
7
|
+
applicationRef;
|
|
8
|
+
static logger = new Logger('ExceptionsHandler');
|
|
9
|
+
httpAdapterHost;
|
|
10
10
|
constructor(applicationRef) {
|
|
11
11
|
this.applicationRef = applicationRef;
|
|
12
12
|
}
|
|
13
13
|
catch(exception, host) {
|
|
14
14
|
const applicationRef = this.applicationRef ||
|
|
15
15
|
(this.httpAdapterHost && this.httpAdapterHost.httpAdapter);
|
|
16
|
-
if (!(exception instanceof
|
|
16
|
+
if (!(exception instanceof HttpException)) {
|
|
17
17
|
return this.handleUnknownError(exception, host, applicationRef);
|
|
18
18
|
}
|
|
19
19
|
const res = exception.getResponse();
|
|
20
|
-
const message =
|
|
20
|
+
const message = isObject(res)
|
|
21
21
|
? res
|
|
22
22
|
: {
|
|
23
23
|
statusCode: exception.getStatus(),
|
|
@@ -38,8 +38,8 @@ class BaseExceptionFilter {
|
|
|
38
38
|
message: exception.message,
|
|
39
39
|
}
|
|
40
40
|
: {
|
|
41
|
-
statusCode:
|
|
42
|
-
message:
|
|
41
|
+
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
42
|
+
message: MESSAGES.UNKNOWN_EXCEPTION_MESSAGE,
|
|
43
43
|
};
|
|
44
44
|
const response = host.getArgByIndex(1);
|
|
45
45
|
if (!applicationRef.isHeadersSent(response)) {
|
|
@@ -48,25 +48,35 @@ class BaseExceptionFilter {
|
|
|
48
48
|
else {
|
|
49
49
|
applicationRef.end(response);
|
|
50
50
|
}
|
|
51
|
-
if (!(exception instanceof
|
|
51
|
+
if (!(exception instanceof IntrinsicException)) {
|
|
52
52
|
BaseExceptionFilter.logger.error(exception);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
isExceptionObject(err) {
|
|
56
|
-
return
|
|
56
|
+
return isObject(err) && !!err.message;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Checks if the thrown error comes from the "http-errors" library.
|
|
59
|
+
* Checks if the thrown error is a FastifyError or comes from the "http-errors" library.
|
|
60
60
|
* @param err error object
|
|
61
61
|
*/
|
|
62
62
|
isHttpError(err) {
|
|
63
|
-
|
|
63
|
+
if (!err || typeof err !== 'object') {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (err.constructor.name === 'FastifyError' &&
|
|
67
|
+
typeof err.code === 'string' &&
|
|
68
|
+
typeof err.statusCode === 'number') {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
// "http-errors" error signature
|
|
72
|
+
return (typeof err.expose === 'boolean' &&
|
|
73
|
+
typeof err.statusCode === 'number' &&
|
|
74
|
+
err.status === err.statusCode &&
|
|
75
|
+
err instanceof Error);
|
|
64
76
|
}
|
|
65
77
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(
|
|
70
|
-
(0, common_1.Inject)(),
|
|
71
|
-
tslib_1.__metadata("design:type", http_adapter_host_1.HttpAdapterHost)
|
|
78
|
+
__decorate([
|
|
79
|
+
Optional(),
|
|
80
|
+
Inject(),
|
|
81
|
+
__metadata("design:type", HttpAdapterHost)
|
|
72
82
|
], BaseExceptionFilter.prototype, "httpAdapterHost", void 0);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpException } from '@nestjs/common';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { HttpException } from '@nestjs/common';
|
|
2
|
+
import { BaseExceptionFilter } from './base-exception-filter.js';
|
|
3
|
+
import { type ExceptionFilterMetadata } from '@nestjs/common/internal';
|
|
4
|
+
import type { ArgumentsHost } from '@nestjs/common';
|
|
5
5
|
export declare class ExceptionsHandler extends BaseExceptionFilter {
|
|
6
6
|
private filters;
|
|
7
7
|
next(exception: Error | HttpException, ctx: ArgumentsHost): void;
|