@nestjs/core 9.0.5 → 9.0.6
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/helpers/external-context-creator.js +1 -1
- package/injector/instance-loader.d.ts +2 -1
- package/injector/instance-loader.js +3 -0
- package/injector/lazy-module-loader-options.interface.d.ts +6 -0
- package/injector/lazy-module-loader-options.interface.js +2 -0
- package/injector/lazy-module-loader.d.ts +3 -1
- package/injector/lazy-module-loader.js +8 -1
- package/injector/silent-logger.d.ts +9 -0
- package/injector/silent-logger.js +18 -0
- package/package.json +2 -2
- package/router/router-execution-context.js +1 -1
|
@@ -121,7 +121,7 @@ class ExternalContextCreator {
|
|
|
121
121
|
const { index, data, pipes: pipesCollection } = metadata[key];
|
|
122
122
|
const pipes = this.pipesContextCreator.createConcreteContext(pipesCollection, contextId, inquirerId);
|
|
123
123
|
const type = this.contextUtils.mapParamType(key);
|
|
124
|
-
if (key.includes(constants_1.
|
|
124
|
+
if (key.includes(constants_1.CUSTOM_ROUTE_ARGS_METADATA)) {
|
|
125
125
|
const { factory } = metadata[key];
|
|
126
126
|
const customExtractValue = this.contextUtils.getCustomFactory(factory, data, contextFactory);
|
|
127
127
|
return { index, extractValue: customExtractValue, type, data, pipes };
|
|
@@ -4,9 +4,10 @@ import { Injector } from './injector';
|
|
|
4
4
|
import { Module } from './module';
|
|
5
5
|
export declare class InstanceLoader {
|
|
6
6
|
protected readonly container: NestContainer;
|
|
7
|
-
private
|
|
7
|
+
private logger;
|
|
8
8
|
protected readonly injector: Injector;
|
|
9
9
|
constructor(container: NestContainer, logger?: Logger);
|
|
10
|
+
setLogger(logger: Logger): void;
|
|
10
11
|
createInstancesOfDependencies(modules?: Map<string, Module>): Promise<void>;
|
|
11
12
|
private createPrototypes;
|
|
12
13
|
private createInstances;
|
|
@@ -13,6 +13,9 @@ class InstanceLoader {
|
|
|
13
13
|
this.logger = logger;
|
|
14
14
|
this.injector = new injector_1.Injector();
|
|
15
15
|
}
|
|
16
|
+
setLogger(logger) {
|
|
17
|
+
this.logger = logger;
|
|
18
|
+
}
|
|
16
19
|
async createInstancesOfDependencies(modules = this.container.getModules()) {
|
|
17
20
|
this.createPrototypes(modules);
|
|
18
21
|
await this.createInstances(modules);
|
|
@@ -2,6 +2,7 @@ import { DynamicModule, Type } from '@nestjs/common';
|
|
|
2
2
|
import { DependenciesScanner } from '../scanner';
|
|
3
3
|
import { ModuleCompiler } from './compiler';
|
|
4
4
|
import { InstanceLoader } from './instance-loader';
|
|
5
|
+
import { LazyModuleLoaderLoadOptions } from './lazy-module-loader-options.interface';
|
|
5
6
|
import { ModuleRef } from './module-ref';
|
|
6
7
|
import { ModulesContainer } from './modules-container';
|
|
7
8
|
export declare class LazyModuleLoader {
|
|
@@ -10,7 +11,8 @@ export declare class LazyModuleLoader {
|
|
|
10
11
|
private readonly moduleCompiler;
|
|
11
12
|
private readonly modulesContainer;
|
|
12
13
|
constructor(dependenciesScanner: DependenciesScanner, instanceLoader: InstanceLoader, moduleCompiler: ModuleCompiler, modulesContainer: ModulesContainer);
|
|
13
|
-
load(loaderFn: () => Promise<Type<unknown> | DynamicModule> | Type<unknown> | DynamicModule): Promise<ModuleRef>;
|
|
14
|
+
load(loaderFn: () => Promise<Type<unknown> | DynamicModule> | Type<unknown> | DynamicModule, loadOpts?: LazyModuleLoaderLoadOptions): Promise<ModuleRef>;
|
|
15
|
+
private registerLoggerConfiguration;
|
|
14
16
|
private createLazyModulesContainer;
|
|
15
17
|
private getTargetModuleRef;
|
|
16
18
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LazyModuleLoader = void 0;
|
|
4
|
+
const silent_logger_1 = require("./silent-logger");
|
|
4
5
|
const module_ref_1 = require("./module-ref");
|
|
5
6
|
class LazyModuleLoader {
|
|
6
7
|
constructor(dependenciesScanner, instanceLoader, moduleCompiler, modulesContainer) {
|
|
@@ -9,7 +10,8 @@ class LazyModuleLoader {
|
|
|
9
10
|
this.moduleCompiler = moduleCompiler;
|
|
10
11
|
this.modulesContainer = modulesContainer;
|
|
11
12
|
}
|
|
12
|
-
async load(loaderFn) {
|
|
13
|
+
async load(loaderFn, loadOpts) {
|
|
14
|
+
this.registerLoggerConfiguration(loadOpts);
|
|
13
15
|
const moduleClassOrDynamicDefinition = await loaderFn();
|
|
14
16
|
const moduleInstances = await this.dependenciesScanner.scanForModules(moduleClassOrDynamicDefinition);
|
|
15
17
|
if (moduleInstances.length === 0) {
|
|
@@ -25,6 +27,11 @@ class LazyModuleLoader {
|
|
|
25
27
|
const [targetModule] = moduleInstances;
|
|
26
28
|
return this.getTargetModuleRef(targetModule);
|
|
27
29
|
}
|
|
30
|
+
registerLoggerConfiguration(loadOpts) {
|
|
31
|
+
if ((loadOpts === null || loadOpts === void 0 ? void 0 : loadOpts.logger) === false) {
|
|
32
|
+
this.instanceLoader.setLogger(new silent_logger_1.SilentLogger());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
28
35
|
createLazyModulesContainer(moduleInstances) {
|
|
29
36
|
moduleInstances = Array.from(new Set(moduleInstances));
|
|
30
37
|
return new Map(moduleInstances.map(ref => [ref.token, ref]));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SilentLogger = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
6
|
+
const noop = () => { };
|
|
7
|
+
class SilentLogger extends common_1.Logger {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.log = noop;
|
|
11
|
+
this.error = noop;
|
|
12
|
+
this.warn = noop;
|
|
13
|
+
this.debug = noop;
|
|
14
|
+
this.verbose = noop;
|
|
15
|
+
this.setLogLevels = noop;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.SilentLogger = SilentLogger;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.6",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"uuid": "8.3.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nestjs/common": "9.0.
|
|
39
|
+
"@nestjs/common": "9.0.6"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^9.0.0",
|
|
@@ -101,7 +101,7 @@ class RouterExecutionContext {
|
|
|
101
101
|
const { index, data, pipes: pipesCollection } = metadata[key];
|
|
102
102
|
const pipes = this.pipesContextCreator.createConcreteContext(pipesCollection, contextId, inquirerId);
|
|
103
103
|
const type = this.contextUtils.mapParamType(key);
|
|
104
|
-
if (key.includes(constants_1.
|
|
104
|
+
if (key.includes(constants_1.CUSTOM_ROUTE_ARGS_METADATA)) {
|
|
105
105
|
const { factory } = metadata[key];
|
|
106
106
|
const customExtractValue = this.contextUtils.getCustomFactory(factory, data, contextFactory);
|
|
107
107
|
return { index, extractValue: customExtractValue, type, data, pipes };
|