@nestjs/core 9.3.0-beta.2 → 9.3.0-beta.3
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpServer } from '@nestjs/common';
|
|
2
2
|
import { MiddlewareConfiguration, RouteInfo } from '@nestjs/common/interfaces/middleware';
|
|
3
|
+
import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
|
|
3
4
|
import { ApplicationConfig } from '../application-config';
|
|
4
5
|
import { NestContainer } from '../injector/container';
|
|
5
6
|
import { Injector } from '../injector/injector';
|
|
@@ -7,10 +8,11 @@ import { Module } from '../injector/module';
|
|
|
7
8
|
import { GraphInspector } from '../inspector/graph-inspector';
|
|
8
9
|
import { RoutePathFactory } from '../router/route-path-factory';
|
|
9
10
|
import { MiddlewareContainer } from './container';
|
|
10
|
-
export declare class MiddlewareModule {
|
|
11
|
+
export declare class MiddlewareModule<TAppOptions extends NestApplicationContextOptions = NestApplicationContextOptions> {
|
|
11
12
|
private readonly routePathFactory;
|
|
12
13
|
private readonly routerProxy;
|
|
13
14
|
private readonly exceptionFiltersCache;
|
|
15
|
+
private readonly logger;
|
|
14
16
|
private injector;
|
|
15
17
|
private routerExceptionFilter;
|
|
16
18
|
private routesMapper;
|
|
@@ -19,8 +21,9 @@ export declare class MiddlewareModule {
|
|
|
19
21
|
private container;
|
|
20
22
|
private httpAdapter;
|
|
21
23
|
private graphInspector;
|
|
24
|
+
private appOptions;
|
|
22
25
|
constructor(routePathFactory: RoutePathFactory);
|
|
23
|
-
register(middlewareContainer: MiddlewareContainer, container: NestContainer, config: ApplicationConfig, injector: Injector, httpAdapter: HttpServer, graphInspector: GraphInspector): Promise<void>;
|
|
26
|
+
register(middlewareContainer: MiddlewareContainer, container: NestContainer, config: ApplicationConfig, injector: Injector, httpAdapter: HttpServer, graphInspector: GraphInspector, options: TAppOptions): Promise<void>;
|
|
24
27
|
resolveMiddleware(middlewareContainer: MiddlewareContainer, modules: Map<string, Module>): Promise<void>;
|
|
25
28
|
loadConfiguration(middlewareContainer: MiddlewareContainer, moduleRef: Module, moduleKey: string): Promise<void>;
|
|
26
29
|
registerMiddleware(middlewareContainer: MiddlewareContainer, applicationRef: any): Promise<void>;
|
|
@@ -21,8 +21,10 @@ class MiddlewareModule {
|
|
|
21
21
|
this.routePathFactory = routePathFactory;
|
|
22
22
|
this.routerProxy = new router_proxy_1.RouterProxy();
|
|
23
23
|
this.exceptionFiltersCache = new WeakMap();
|
|
24
|
+
this.logger = new common_1.Logger(MiddlewareModule.name);
|
|
24
25
|
}
|
|
25
|
-
async register(middlewareContainer, container, config, injector, httpAdapter, graphInspector) {
|
|
26
|
+
async register(middlewareContainer, container, config, injector, httpAdapter, graphInspector, options) {
|
|
27
|
+
this.appOptions = options;
|
|
26
28
|
const appRef = container.getHttpAdapterRef();
|
|
27
29
|
this.routerExceptionFilter = new router_exception_filters_1.RouterExceptionFilters(container, config, appRef);
|
|
28
30
|
this.routesMapper = new routes_mapper_1.RoutesMapper(container);
|
|
@@ -49,7 +51,17 @@ class MiddlewareModule {
|
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
53
|
const middlewareBuilder = new builder_1.MiddlewareBuilder(this.routesMapper, this.httpAdapter);
|
|
52
|
-
|
|
54
|
+
try {
|
|
55
|
+
await instance.configure(middlewareBuilder);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
if (!this.appOptions.preview) {
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
const warningMessage = `Warning! "${moduleRef.name}" module exposes a "configure" method that throws an exception in the preview mode` +
|
|
62
|
+
` (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
|
+
this.logger.warn(warningMessage);
|
|
64
|
+
}
|
|
53
65
|
if (!(middlewareBuilder instanceof builder_1.MiddlewareBuilder)) {
|
|
54
66
|
return;
|
|
55
67
|
}
|
package/nest-application.js
CHANGED
|
@@ -80,7 +80,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
|
|
|
80
80
|
this.microservicesModule.register(this.container, this.graphInspector, this.config, this.appOptions);
|
|
81
81
|
this.microservicesModule.setupClients(this.container);
|
|
82
82
|
}
|
|
83
|
-
await this.middlewareModule.register(this.middlewareContainer, this.container, this.config, this.injector, this.httpAdapter, this.graphInspector);
|
|
83
|
+
await this.middlewareModule.register(this.middlewareContainer, this.container, this.config, this.injector, this.httpAdapter, this.graphInspector, this.appOptions);
|
|
84
84
|
}
|
|
85
85
|
registerWsModule() {
|
|
86
86
|
if (!this.socketModule) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "9.3.0-beta.
|
|
3
|
+
"version": "9.3.0-beta.3",
|
|
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": "9.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nestjs/common": "^9.3.0-beta.
|
|
39
|
+
"@nestjs/common": "^9.3.0-beta.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^9.0.0",
|