@nestjs/core 8.3.0 → 8.3.1
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/Readme.md +1 -0
- package/adapters/index.js +1 -1
- package/discovery/discovery-module.js +2 -2
- package/discovery/discovery-service.js +5 -5
- package/discovery/index.js +2 -2
- package/errors/exceptions/invalid-class-module.exception.js +1 -1
- package/errors/exceptions/invalid-class-scope.exception.js +2 -2
- package/errors/exceptions/invalid-class.exception.js +1 -1
- package/errors/exceptions/invalid-middleware.exception.js +1 -1
- package/errors/exceptions/invalid-module.exception.js +1 -1
- package/errors/exceptions/undefined-dependency.exception.js +1 -1
- package/errors/exceptions/undefined-forwardref.exception.js +1 -1
- package/errors/exceptions/undefined-module.exception.js +1 -1
- package/errors/exceptions/unknown-dependencies.exception.js +1 -1
- package/errors/exceptions/unknown-export.exception.js +1 -1
- package/errors/messages.js +3 -3
- package/exceptions/base-exception-filter-context.js +3 -3
- package/exceptions/base-exception-filter.js +6 -6
- package/exceptions/exceptions-handler.js +1 -1
- package/exceptions/external-exception-filter-context.js +2 -2
- package/exceptions/external-exceptions-handler.js +1 -1
- package/exceptions/index.js +1 -1
- package/guards/guards-consumer.js +2 -2
- package/guards/guards-context-creator.js +4 -4
- package/helpers/context-utils.js +1 -1
- package/helpers/external-context-creator.js +3 -3
- package/helpers/index.js +2 -2
- package/helpers/interfaces/index.js +2 -2
- package/hooks/before-app-shutdown.hook.js +5 -5
- package/hooks/index.js +5 -5
- package/hooks/on-app-bootstrap.hook.js +5 -5
- package/hooks/on-app-shutdown.hook.js +5 -5
- package/hooks/on-module-destroy.hook.js +5 -5
- package/hooks/on-module-init.hook.js +5 -5
- package/index.js +12 -12
- package/injector/compiler.js +1 -1
- package/injector/helpers/transient-instances.js +2 -2
- package/injector/index.js +5 -5
- package/injector/injector.js +13 -13
- package/injector/inquirer/index.js +1 -1
- package/injector/instance-links-host.js +1 -1
- package/injector/instance-loader.js +1 -1
- package/injector/instance-wrapper.js +7 -7
- package/injector/internal-core-module.js +3 -3
- package/injector/module-ref.js +1 -1
- package/injector/module-token-factory.js +4 -4
- package/injector/module.js +18 -18
- package/injector/modules-container.js +1 -1
- package/interceptors/interceptors-consumer.js +4 -4
- package/interceptors/interceptors-context-creator.js +4 -4
- package/metadata-scanner.js +4 -4
- package/middleware/builder.js +3 -3
- package/middleware/container.js +1 -1
- package/middleware/index.js +1 -1
- package/middleware/middleware-module.js +6 -6
- package/middleware/routes-mapper.js +6 -6
- package/middleware/utils.js +6 -6
- package/nest-application-context.js +8 -8
- package/nest-application.js +13 -13
- package/nest-factory.js +6 -6
- package/package.json +2 -2
- package/pipes/pipes-context-creator.js +4 -4
- package/router/index.js +2 -2
- package/router/interfaces/index.js +1 -1
- package/router/route-path-factory.js +8 -8
- package/router/router-exception-filters.js +2 -2
- package/router/router-execution-context.js +4 -4
- package/router/router-explorer.js +12 -12
- package/router/router-module.js +6 -6
- package/router/router-response-controller.js +6 -6
- package/router/routes-resolver.js +2 -2
- package/router/sse-stream.js +1 -1
- package/router/utils/exclude-route.util.js +1 -1
- package/router/utils/flatten-route-paths.util.js +2 -2
- package/router/utils/index.js +2 -2
- package/scanner.js +9 -9
- package/services/index.js +1 -1
- package/services/reflector.service.js +2 -2
package/Readme.md
CHANGED
|
@@ -123,6 +123,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
123
123
|
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
|
124
124
|
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
|
125
125
|
<td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
|
|
126
|
+
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
|
126
127
|
</tr></table>
|
|
127
128
|
|
|
128
129
|
## Backers
|
package/adapters/index.js
CHANGED
|
@@ -10,8 +10,8 @@ const discovery_service_1 = require("./discovery-service");
|
|
|
10
10
|
*/
|
|
11
11
|
let DiscoveryModule = class DiscoveryModule {
|
|
12
12
|
};
|
|
13
|
-
DiscoveryModule =
|
|
14
|
-
|
|
13
|
+
DiscoveryModule = tslib_1.__decorate([
|
|
14
|
+
common_1.Module({
|
|
15
15
|
providers: [metadata_scanner_1.MetadataScanner, discovery_service_1.DiscoveryService],
|
|
16
16
|
exports: [metadata_scanner_1.MetadataScanner, discovery_service_1.DiscoveryService],
|
|
17
17
|
})
|
|
@@ -13,11 +13,11 @@ let DiscoveryService = class DiscoveryService {
|
|
|
13
13
|
}
|
|
14
14
|
getProviders(options = {}, modules = this.getModules(options)) {
|
|
15
15
|
const providers = modules.map(item => [...item.providers.values()]);
|
|
16
|
-
return
|
|
16
|
+
return common_1.flatten(providers);
|
|
17
17
|
}
|
|
18
18
|
getControllers(options = {}, modules = this.getModules(options)) {
|
|
19
19
|
const controllers = modules.map(item => [...item.controllers.values()]);
|
|
20
|
-
return
|
|
20
|
+
return common_1.flatten(controllers);
|
|
21
21
|
}
|
|
22
22
|
getModules(options = {}) {
|
|
23
23
|
if (!options.include) {
|
|
@@ -32,8 +32,8 @@ let DiscoveryService = class DiscoveryService {
|
|
|
32
32
|
return moduleRefs.filter(({ metatype }) => include.some(item => item === metatype));
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
DiscoveryService =
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
DiscoveryService = tslib_1.__decorate([
|
|
36
|
+
common_1.Injectable(),
|
|
37
|
+
tslib_1.__metadata("design:paramtypes", [modules_container_1.ModulesContainer])
|
|
38
38
|
], DiscoveryService);
|
|
39
39
|
exports.DiscoveryService = DiscoveryService;
|
package/discovery/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./discovery-module"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./discovery-service"), exports);
|
|
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
|
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class InvalidClassModuleException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(metatypeUsedAsAModule, scope) {
|
|
8
|
-
super(
|
|
8
|
+
super(messages_1.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE(metatypeUsedAsAModule, scope));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.InvalidClassModuleException = InvalidClassModuleException;
|
|
@@ -6,11 +6,11 @@ const messages_1 = require("../messages");
|
|
|
6
6
|
const runtime_exception_1 = require("./runtime.exception");
|
|
7
7
|
class InvalidClassScopeException extends runtime_exception_1.RuntimeException {
|
|
8
8
|
constructor(metatypeOrToken) {
|
|
9
|
-
let name =
|
|
9
|
+
let name = shared_utils_1.isFunction(metatypeOrToken)
|
|
10
10
|
? metatypeOrToken.name
|
|
11
11
|
: metatypeOrToken;
|
|
12
12
|
name = name && name.toString();
|
|
13
|
-
super(
|
|
13
|
+
super(messages_1.INVALID_CLASS_SCOPE_MESSAGE `${name}`);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.InvalidClassScopeException = InvalidClassScopeException;
|
|
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
|
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class InvalidClassException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(value) {
|
|
8
|
-
super(
|
|
8
|
+
super(messages_1.INVALID_CLASS_MESSAGE `${value}`);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.InvalidClassException = InvalidClassException;
|
|
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
|
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class InvalidMiddlewareException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(name) {
|
|
8
|
-
super(
|
|
8
|
+
super(messages_1.INVALID_MIDDLEWARE_MESSAGE `${name}`);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.InvalidMiddlewareException = InvalidMiddlewareException;
|
|
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
|
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class InvalidModuleException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(parentModule, index, scope) {
|
|
8
|
-
super(
|
|
8
|
+
super(messages_1.INVALID_MODULE_MESSAGE(parentModule, index, scope));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.InvalidModuleException = InvalidModuleException;
|
|
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
|
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class UndefinedDependencyException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(type, undefinedDependencyContext, module) {
|
|
8
|
-
super(
|
|
8
|
+
super(messages_1.UNKNOWN_DEPENDENCIES_MESSAGE(type, undefinedDependencyContext, module));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.UndefinedDependencyException = UndefinedDependencyException;
|
|
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
|
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class UndefinedForwardRefException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(scope) {
|
|
8
|
-
super(
|
|
8
|
+
super(messages_1.UNDEFINED_FORWARDREF_MESSAGE(scope));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.UndefinedForwardRefException = UndefinedForwardRefException;
|
|
@@ -5,7 +5,7 @@ const runtime_exception_1 = require("./runtime.exception");
|
|
|
5
5
|
const messages_1 = require("../messages");
|
|
6
6
|
class UndefinedModuleException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(parentModule, index, scope) {
|
|
8
|
-
super(
|
|
8
|
+
super(messages_1.UNDEFINED_MODULE_MESSAGE(parentModule, index, scope));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.UndefinedModuleException = UndefinedModuleException;
|
|
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
|
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class UnknownDependenciesException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(type, unknownDependencyContext, module) {
|
|
8
|
-
super(
|
|
8
|
+
super(messages_1.UNKNOWN_DEPENDENCIES_MESSAGE(type, unknownDependencyContext, module));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.UnknownDependenciesException = UnknownDependenciesException;
|
|
@@ -5,7 +5,7 @@ const messages_1 = require("../messages");
|
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class UnknownExportException extends runtime_exception_1.RuntimeException {
|
|
7
7
|
constructor(token, moduleName) {
|
|
8
|
-
super(
|
|
8
|
+
super(messages_1.UNKNOWN_EXPORT_MESSAGE(token, moduleName));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.UnknownExportException = UnknownExportException;
|
package/errors/messages.js
CHANGED
|
@@ -26,7 +26,7 @@ const getDependencyName = (dependency) =>
|
|
|
26
26
|
// use class name
|
|
27
27
|
getInstanceName(dependency) ||
|
|
28
28
|
// use injection token (symbol)
|
|
29
|
-
(
|
|
29
|
+
(shared_utils_1.isSymbol(dependency) && dependency.toString()) ||
|
|
30
30
|
// use string directly
|
|
31
31
|
dependency ||
|
|
32
32
|
// otherwise
|
|
@@ -51,7 +51,7 @@ Potential solutions:
|
|
|
51
51
|
imports: [ /* the Module containing ${dependencyName} */ ]
|
|
52
52
|
})
|
|
53
53
|
`;
|
|
54
|
-
if (
|
|
54
|
+
if (shared_utils_1.isNil(index)) {
|
|
55
55
|
message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
|
|
56
56
|
return message;
|
|
57
57
|
}
|
|
@@ -103,7 +103,7 @@ Scope [${stringifyScope(scope)}]`;
|
|
|
103
103
|
};
|
|
104
104
|
exports.UNDEFINED_MODULE_MESSAGE = UNDEFINED_MODULE_MESSAGE;
|
|
105
105
|
const UNKNOWN_EXPORT_MESSAGE = (token = 'item', module) => {
|
|
106
|
-
token =
|
|
106
|
+
token = shared_utils_1.isSymbol(token) ? token.toString() : token;
|
|
107
107
|
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.
|
|
108
108
|
|
|
109
109
|
Possible Solutions:
|
|
@@ -12,11 +12,11 @@ class BaseExceptionFilterContext extends context_creator_1.ContextCreator {
|
|
|
12
12
|
this.container = container;
|
|
13
13
|
}
|
|
14
14
|
createConcreteContext(metadata, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
|
|
15
|
-
if (
|
|
15
|
+
if (shared_utils_1.isEmpty(metadata)) {
|
|
16
16
|
return [];
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
.filter(instance => instance && (
|
|
18
|
+
return iterare_1.iterate(metadata)
|
|
19
|
+
.filter(instance => instance && (shared_utils_1.isFunction(instance.catch) || instance.name))
|
|
20
20
|
.map(filter => this.getFilterInstance(filter, contextId, inquirerId))
|
|
21
21
|
.filter(item => !!item)
|
|
22
22
|
.map(instance => ({
|
|
@@ -17,7 +17,7 @@ class BaseExceptionFilter {
|
|
|
17
17
|
return this.handleUnknownError(exception, host, applicationRef);
|
|
18
18
|
}
|
|
19
19
|
const res = exception.getResponse();
|
|
20
|
-
const message =
|
|
20
|
+
const message = shared_utils_1.isObject(res)
|
|
21
21
|
? res
|
|
22
22
|
: {
|
|
23
23
|
statusCode: exception.getStatus(),
|
|
@@ -42,7 +42,7 @@ class BaseExceptionFilter {
|
|
|
42
42
|
return BaseExceptionFilter.logger.error(exception);
|
|
43
43
|
}
|
|
44
44
|
isExceptionObject(err) {
|
|
45
|
-
return
|
|
45
|
+
return shared_utils_1.isObject(err) && !!err.message;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Checks if the thrown error comes from the "http-errors" library.
|
|
@@ -53,9 +53,9 @@ class BaseExceptionFilter {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
BaseExceptionFilter.logger = new common_1.Logger('ExceptionsHandler');
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
tslib_1.__decorate([
|
|
57
|
+
common_1.Optional(),
|
|
58
|
+
common_1.Inject(),
|
|
59
|
+
tslib_1.__metadata("design:type", http_adapter_host_1.HttpAdapterHost)
|
|
60
60
|
], BaseExceptionFilter.prototype, "httpAdapterHost", void 0);
|
|
61
61
|
exports.BaseExceptionFilter = BaseExceptionFilter;
|
|
@@ -22,7 +22,7 @@ class ExceptionsHandler extends base_exception_filter_1.BaseExceptionFilter {
|
|
|
22
22
|
this.filters = filters;
|
|
23
23
|
}
|
|
24
24
|
invokeCustomFilters(exception, ctx) {
|
|
25
|
-
if (
|
|
25
|
+
if (shared_utils_1.isEmpty(this.filters)) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
const isInstanceOf = (metatype) => exception instanceof metatype;
|
|
@@ -16,7 +16,7 @@ class ExternalExceptionFilterContext extends base_exception_filter_context_1.Bas
|
|
|
16
16
|
this.moduleContext = module;
|
|
17
17
|
const exceptionHandler = new external_exceptions_handler_1.ExternalExceptionsHandler();
|
|
18
18
|
const filters = this.createContext(instance, callback, constants_1.EXCEPTION_FILTERS_METADATA, contextId, inquirerId);
|
|
19
|
-
if (
|
|
19
|
+
if (shared_utils_1.isEmpty(filters)) {
|
|
20
20
|
return exceptionHandler;
|
|
21
21
|
}
|
|
22
22
|
exceptionHandler.setCustomFilters(filters.reverse());
|
|
@@ -31,7 +31,7 @@ class ExternalExceptionFilterContext extends base_exception_filter_context_1.Bas
|
|
|
31
31
|
return globalFilters;
|
|
32
32
|
}
|
|
33
33
|
const scopedFilterWrappers = this.config.getGlobalRequestFilters();
|
|
34
|
-
const scopedFilters =
|
|
34
|
+
const scopedFilters = iterare_1.iterate(scopedFilterWrappers)
|
|
35
35
|
.map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
|
|
36
36
|
.filter(host => !!host)
|
|
37
37
|
.map(host => host.instance)
|
|
@@ -23,7 +23,7 @@ class ExternalExceptionsHandler extends external_exception_filter_1.ExternalExce
|
|
|
23
23
|
this.filters = filters;
|
|
24
24
|
}
|
|
25
25
|
invokeCustomFilters(exception, host) {
|
|
26
|
-
if (
|
|
26
|
+
if (shared_utils_1.isEmpty(this.filters)) {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
const isInstanceOf = (metatype) => exception instanceof metatype;
|
package/exceptions/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const rxjs_1 = require("rxjs");
|
|
|
6
6
|
const execution_context_host_1 = require("../helpers/execution-context-host");
|
|
7
7
|
class GuardsConsumer {
|
|
8
8
|
async tryActivate(guards, args, instance, callback, type) {
|
|
9
|
-
if (!guards ||
|
|
9
|
+
if (!guards || shared_utils_1.isEmpty(guards)) {
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
12
12
|
const context = this.createContext(args, instance, callback);
|
|
@@ -25,7 +25,7 @@ class GuardsConsumer {
|
|
|
25
25
|
}
|
|
26
26
|
async pickResult(result) {
|
|
27
27
|
if (result instanceof rxjs_1.Observable) {
|
|
28
|
-
return
|
|
28
|
+
return rxjs_1.lastValueFrom(result);
|
|
29
29
|
}
|
|
30
30
|
return result;
|
|
31
31
|
}
|
|
@@ -17,13 +17,13 @@ class GuardsContextCreator extends context_creator_1.ContextCreator {
|
|
|
17
17
|
return this.createContext(instance, callback, constants_1.GUARDS_METADATA, contextId, inquirerId);
|
|
18
18
|
}
|
|
19
19
|
createConcreteContext(metadata, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
|
|
20
|
-
if (
|
|
20
|
+
if (shared_utils_1.isEmpty(metadata)) {
|
|
21
21
|
return [];
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return iterare_1.iterate(metadata)
|
|
24
24
|
.filter((guard) => guard && (guard.name || guard.canActivate))
|
|
25
25
|
.map(guard => this.getGuardInstance(guard, contextId, inquirerId))
|
|
26
|
-
.filter((guard) => guard &&
|
|
26
|
+
.filter((guard) => guard && shared_utils_1.isFunction(guard.canActivate))
|
|
27
27
|
.toArray();
|
|
28
28
|
}
|
|
29
29
|
getGuardInstance(metatype, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
|
|
@@ -59,7 +59,7 @@ class GuardsContextCreator extends context_creator_1.ContextCreator {
|
|
|
59
59
|
return globalGuards;
|
|
60
60
|
}
|
|
61
61
|
const scopedGuardWrappers = this.config.getGlobalRequestGuards();
|
|
62
|
-
const scopedGuards =
|
|
62
|
+
const scopedGuards = iterare_1.iterate(scopedGuardWrappers)
|
|
63
63
|
.map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
|
|
64
64
|
.filter(host => !!host)
|
|
65
65
|
.map(host => host.instance)
|
package/helpers/context-utils.js
CHANGED
|
@@ -36,7 +36,7 @@ class ContextUtils {
|
|
|
36
36
|
return paramsProperties.map(param => (Object.assign(Object.assign({}, param), { metatype: paramtypes[param.index] })));
|
|
37
37
|
}
|
|
38
38
|
getCustomFactory(factory, data, contextFactory) {
|
|
39
|
-
return
|
|
39
|
+
return shared_utils_1.isFunction(factory)
|
|
40
40
|
? (...args) => factory(data, contextFactory(args))
|
|
41
41
|
: () => null;
|
|
42
42
|
}
|
|
@@ -143,13 +143,13 @@ class ExternalContextCreator {
|
|
|
143
143
|
return paramsOptions.length ? pipesFn : null;
|
|
144
144
|
}
|
|
145
145
|
async getParamValue(value, { metatype, type, data }, pipes) {
|
|
146
|
-
return
|
|
146
|
+
return shared_utils_1.isEmpty(pipes)
|
|
147
147
|
? value
|
|
148
148
|
: this.pipesConsumer.apply(value, { metatype, type, data }, pipes);
|
|
149
149
|
}
|
|
150
150
|
async transformToResult(resultOrDeferred) {
|
|
151
|
-
if (
|
|
152
|
-
return
|
|
151
|
+
if (rxjs_1.isObservable(resultOrDeferred)) {
|
|
152
|
+
return rxjs_1.lastValueFrom(resultOrDeferred);
|
|
153
153
|
}
|
|
154
154
|
return resultOrDeferred;
|
|
155
155
|
}
|
package/helpers/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./context-id-factory"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./http-adapter-host"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./external-handler-metadata.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./params-metadata.interface"), exports);
|
|
@@ -10,14 +10,14 @@ const transient_instances_1 = require("../injector/helpers/transient-instances")
|
|
|
10
10
|
* @param instance The instance which should be checked
|
|
11
11
|
*/
|
|
12
12
|
function hasBeforeApplicationShutdownHook(instance) {
|
|
13
|
-
return
|
|
13
|
+
return shared_utils_1.isFunction(instance.beforeApplicationShutdown);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Calls the given instances
|
|
17
17
|
*/
|
|
18
18
|
function callOperator(instances, signal) {
|
|
19
|
-
return
|
|
20
|
-
.filter(instance => !
|
|
19
|
+
return iterare_1.iterate(instances)
|
|
20
|
+
.filter(instance => !shared_utils_1.isNil(instance))
|
|
21
21
|
.filter(hasBeforeApplicationShutdownHook)
|
|
22
22
|
.map(async (instance) => instance.beforeApplicationShutdown(signal))
|
|
23
23
|
.toArray();
|
|
@@ -38,9 +38,9 @@ async function callBeforeAppShutdownHook(module, signal) {
|
|
|
38
38
|
...module.injectables,
|
|
39
39
|
...module.middlewares,
|
|
40
40
|
];
|
|
41
|
-
const nonTransientInstances =
|
|
41
|
+
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
42
42
|
await Promise.all(callOperator(nonTransientInstances, signal));
|
|
43
|
-
const transientInstances =
|
|
43
|
+
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
44
44
|
await Promise.all(callOperator(transientInstances, signal));
|
|
45
45
|
const moduleClassInstance = moduleClassHost.instance;
|
|
46
46
|
if (moduleClassInstance &&
|
package/hooks/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./on-app-bootstrap.hook"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./on-app-shutdown.hook"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./on-module-destroy.hook"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./on-module-init.hook"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./before-app-shutdown.hook"), exports);
|
|
@@ -10,14 +10,14 @@ const transient_instances_1 = require("../injector/helpers/transient-instances")
|
|
|
10
10
|
* @param instance The instance which should be checked
|
|
11
11
|
*/
|
|
12
12
|
function hasOnAppBootstrapHook(instance) {
|
|
13
|
-
return
|
|
13
|
+
return shared_utils_1.isFunction(instance.onApplicationBootstrap);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Calls the given instances
|
|
17
17
|
*/
|
|
18
18
|
function callOperator(instances) {
|
|
19
|
-
return
|
|
20
|
-
.filter(instance => !
|
|
19
|
+
return iterare_1.iterate(instances)
|
|
20
|
+
.filter(instance => !shared_utils_1.isNil(instance))
|
|
21
21
|
.filter(hasOnAppBootstrapHook)
|
|
22
22
|
.map(async (instance) => instance.onApplicationBootstrap())
|
|
23
23
|
.toArray();
|
|
@@ -39,9 +39,9 @@ async function callModuleBootstrapHook(module) {
|
|
|
39
39
|
...module.injectables,
|
|
40
40
|
...module.middlewares,
|
|
41
41
|
];
|
|
42
|
-
const nonTransientInstances =
|
|
42
|
+
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
43
43
|
await Promise.all(callOperator(nonTransientInstances));
|
|
44
|
-
const transientInstances =
|
|
44
|
+
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
45
45
|
await Promise.all(callOperator(transientInstances));
|
|
46
46
|
// Call the instance itself
|
|
47
47
|
const moduleClassInstance = moduleClassHost.instance;
|
|
@@ -10,14 +10,14 @@ const transient_instances_1 = require("../injector/helpers/transient-instances")
|
|
|
10
10
|
* @param instance The instance which should be checked
|
|
11
11
|
*/
|
|
12
12
|
function hasOnAppShutdownHook(instance) {
|
|
13
|
-
return
|
|
13
|
+
return shared_utils_1.isFunction(instance.onApplicationShutdown);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Calls the given instances
|
|
17
17
|
*/
|
|
18
18
|
function callOperator(instances, signal) {
|
|
19
|
-
return
|
|
20
|
-
.filter(instance => !
|
|
19
|
+
return iterare_1.iterate(instances)
|
|
20
|
+
.filter(instance => !shared_utils_1.isNil(instance))
|
|
21
21
|
.filter(hasOnAppShutdownHook)
|
|
22
22
|
.map(async (instance) => instance.onApplicationShutdown(signal))
|
|
23
23
|
.toArray();
|
|
@@ -39,9 +39,9 @@ async function callAppShutdownHook(module, signal) {
|
|
|
39
39
|
...module.injectables,
|
|
40
40
|
...module.middlewares,
|
|
41
41
|
];
|
|
42
|
-
const nonTransientInstances =
|
|
42
|
+
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
43
43
|
await Promise.all(callOperator(nonTransientInstances, signal));
|
|
44
|
-
const transientInstances =
|
|
44
|
+
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
45
45
|
await Promise.all(callOperator(transientInstances, signal));
|
|
46
46
|
// Call the instance itself
|
|
47
47
|
const moduleClassInstance = moduleClassHost.instance;
|
|
@@ -10,14 +10,14 @@ const transient_instances_1 = require("../injector/helpers/transient-instances")
|
|
|
10
10
|
* @param instance The instance which should be checked
|
|
11
11
|
*/
|
|
12
12
|
function hasOnModuleDestroyHook(instance) {
|
|
13
|
-
return
|
|
13
|
+
return shared_utils_1.isFunction(instance.onModuleDestroy);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Calls the given instances onModuleDestroy hook
|
|
17
17
|
*/
|
|
18
18
|
function callOperator(instances) {
|
|
19
|
-
return
|
|
20
|
-
.filter(instance => !
|
|
19
|
+
return iterare_1.iterate(instances)
|
|
20
|
+
.filter(instance => !shared_utils_1.isNil(instance))
|
|
21
21
|
.filter(hasOnModuleDestroyHook)
|
|
22
22
|
.map(async (instance) => instance.onModuleDestroy())
|
|
23
23
|
.toArray();
|
|
@@ -39,9 +39,9 @@ async function callModuleDestroyHook(module) {
|
|
|
39
39
|
...module.injectables,
|
|
40
40
|
...module.middlewares,
|
|
41
41
|
];
|
|
42
|
-
const nonTransientInstances =
|
|
42
|
+
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
43
43
|
await Promise.all(callOperator(nonTransientInstances));
|
|
44
|
-
const transientInstances =
|
|
44
|
+
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
45
45
|
await Promise.all(callOperator(transientInstances));
|
|
46
46
|
// Call the module instance itself
|
|
47
47
|
const moduleClassInstance = moduleClassHost.instance;
|
|
@@ -10,14 +10,14 @@ const transient_instances_1 = require("../injector/helpers/transient-instances")
|
|
|
10
10
|
* @param instance The instance which should be checked
|
|
11
11
|
*/
|
|
12
12
|
function hasOnModuleInitHook(instance) {
|
|
13
|
-
return
|
|
13
|
+
return shared_utils_1.isFunction(instance.onModuleInit);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Calls the given instances
|
|
17
17
|
*/
|
|
18
18
|
function callOperator(instances) {
|
|
19
|
-
return
|
|
20
|
-
.filter(instance => !
|
|
19
|
+
return iterare_1.iterate(instances)
|
|
20
|
+
.filter(instance => !shared_utils_1.isNil(instance))
|
|
21
21
|
.filter(hasOnModuleInitHook)
|
|
22
22
|
.map(async (instance) => instance.onModuleInit())
|
|
23
23
|
.toArray();
|
|
@@ -39,9 +39,9 @@ async function callModuleInitHook(module) {
|
|
|
39
39
|
...module.injectables,
|
|
40
40
|
...module.middlewares,
|
|
41
41
|
];
|
|
42
|
-
const nonTransientInstances =
|
|
42
|
+
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
43
43
|
await Promise.all(callOperator(nonTransientInstances));
|
|
44
|
-
const transientInstances =
|
|
44
|
+
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
45
45
|
await Promise.all(callOperator(transientInstances));
|
|
46
46
|
// Call the instance itself
|
|
47
47
|
const moduleClassInstance = moduleClassHost.instance;
|
package/index.js
CHANGED
|
@@ -9,22 +9,22 @@ const tslib_1 = require("tslib");
|
|
|
9
9
|
* MIT Licensed
|
|
10
10
|
*/
|
|
11
11
|
require("reflect-metadata");
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
tslib_1.__exportStar(require("./adapters"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./application-config"), exports);
|
|
14
14
|
var constants_1 = require("./constants");
|
|
15
15
|
Object.defineProperty(exports, "APP_FILTER", { enumerable: true, get: function () { return constants_1.APP_FILTER; } });
|
|
16
16
|
Object.defineProperty(exports, "APP_GUARD", { enumerable: true, get: function () { return constants_1.APP_GUARD; } });
|
|
17
17
|
Object.defineProperty(exports, "APP_INTERCEPTOR", { enumerable: true, get: function () { return constants_1.APP_INTERCEPTOR; } });
|
|
18
18
|
Object.defineProperty(exports, "APP_PIPE", { enumerable: true, get: function () { return constants_1.APP_PIPE; } });
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
tslib_1.__exportStar(require("./discovery"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./exceptions"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./helpers"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./injector"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./metadata-scanner"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./middleware"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./nest-application"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./nest-application-context"), exports);
|
|
27
27
|
var nest_factory_1 = require("./nest-factory");
|
|
28
28
|
Object.defineProperty(exports, "NestFactory", { enumerable: true, get: function () { return nest_factory_1.NestFactory; } });
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
tslib_1.__exportStar(require("./router"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./services"), exports);
|
package/injector/compiler.js
CHANGED
|
@@ -16,7 +16,7 @@ class ModuleCompiler {
|
|
|
16
16
|
if (!this.isDynamicModule(metatype)) {
|
|
17
17
|
return { type: metatype };
|
|
18
18
|
}
|
|
19
|
-
const { module: type } = metatype, dynamicMetadata =
|
|
19
|
+
const { module: type } = metatype, dynamicMetadata = tslib_1.__rest(metatype, ["module"]);
|
|
20
20
|
return { type, dynamicMetadata };
|
|
21
21
|
}
|
|
22
22
|
isDynamicModule(module) {
|
|
@@ -7,7 +7,7 @@ const iterare_1 = require("iterare");
|
|
|
7
7
|
* @param instances The instances which should be checked whether they are transcient
|
|
8
8
|
*/
|
|
9
9
|
function getTransientInstances(instances) {
|
|
10
|
-
return
|
|
10
|
+
return iterare_1.iterate(instances)
|
|
11
11
|
.filter(([_, wrapper]) => wrapper.isDependencyTreeStatic())
|
|
12
12
|
.map(([_, wrapper]) => wrapper.getStaticTransientInstances())
|
|
13
13
|
.flatten()
|
|
@@ -21,7 +21,7 @@ exports.getTransientInstances = getTransientInstances;
|
|
|
21
21
|
* @param instances The instances which should be checked whether they are transcient
|
|
22
22
|
*/
|
|
23
23
|
function getNonTransientInstances(instances) {
|
|
24
|
-
return
|
|
24
|
+
return iterare_1.iterate(instances)
|
|
25
25
|
.filter(([key, wrapper]) => wrapper.isDependencyTreeStatic() && !wrapper.isTransient)
|
|
26
26
|
.map(([key, { instance }]) => instance)
|
|
27
27
|
.toArray();
|