@nestjs/core 7.6.8 → 7.6.9
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.9",
|
|
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": "7.6.
|
|
39
|
+
"@nestjs/common": "7.6.9"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^7.0.0",
|
|
@@ -27,11 +27,11 @@ export declare class RouterExplorer {
|
|
|
27
27
|
private readonly logger;
|
|
28
28
|
private readonly exceptionFiltersCache;
|
|
29
29
|
constructor(metadataScanner: MetadataScanner, container: NestContainer, injector?: Injector, routerProxy?: RouterProxy, exceptionsFilter?: ExceptionsFilter, config?: ApplicationConfig);
|
|
30
|
-
explore<T extends HttpServer = any>(instanceWrapper: InstanceWrapper, module: string, applicationRef: T, basePath: string, host: string): void;
|
|
30
|
+
explore<T extends HttpServer = any>(instanceWrapper: InstanceWrapper, module: string, applicationRef: T, basePath: string, host: string | string[]): void;
|
|
31
31
|
extractRouterPath(metatype: Type<Controller>, prefix?: string): string[];
|
|
32
32
|
scanForPaths(instance: Controller, prototype?: object): RoutePathProperties[];
|
|
33
33
|
exploreMethodMetadata(instance: Controller, prototype: object, methodName: string): RoutePathProperties;
|
|
34
|
-
applyPathsToRouterProxy<T extends HttpServer>(router: T, routePaths: RoutePathProperties[], instanceWrapper: InstanceWrapper, moduleKey: string, basePath: string, host: string): void;
|
|
34
|
+
applyPathsToRouterProxy<T extends HttpServer>(router: T, routePaths: RoutePathProperties[], instanceWrapper: InstanceWrapper, moduleKey: string, basePath: string, host: string | string[]): void;
|
|
35
35
|
stripEndSlash(str: string): string;
|
|
36
36
|
private applyCallbackToRouter;
|
|
37
37
|
private applyHostFilter;
|
|
@@ -108,18 +108,27 @@ class RouterExplorer {
|
|
|
108
108
|
return handler;
|
|
109
109
|
}
|
|
110
110
|
const httpAdapterRef = this.container.getHttpAdapterRef();
|
|
111
|
-
const
|
|
112
|
-
const
|
|
111
|
+
const hosts = Array.isArray(host) ? host : [host];
|
|
112
|
+
const hostRegExps = hosts.map((host) => {
|
|
113
|
+
const keys = [];
|
|
114
|
+
const regexp = pathToRegexp(host, keys);
|
|
115
|
+
return { regexp, keys };
|
|
116
|
+
});
|
|
117
|
+
const unsupportedFilteringErrorMessage = Array.isArray(host)
|
|
118
|
+
? `HTTP adapter does not support filtering on hosts: ["${host.join('", "')}"]`
|
|
119
|
+
: `HTTP adapter does not support filtering on host: "${host}"`;
|
|
113
120
|
return (req, res, next) => {
|
|
114
121
|
req.hosts = {};
|
|
115
122
|
const hostname = httpAdapterRef.getRequestHostname(req) || '';
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
for (const exp of hostRegExps) {
|
|
124
|
+
const match = hostname.match(exp.regexp);
|
|
125
|
+
if (match) {
|
|
126
|
+
exp.keys.forEach((key, i) => (req.hosts[key.name] = match[i + 1]));
|
|
127
|
+
return handler(req, res, next);
|
|
128
|
+
}
|
|
120
129
|
}
|
|
121
130
|
if (!next) {
|
|
122
|
-
throw new exceptions_1.InternalServerErrorException(
|
|
131
|
+
throw new exceptions_1.InternalServerErrorException(unsupportedFilteringErrorMessage);
|
|
123
132
|
}
|
|
124
133
|
return next();
|
|
125
134
|
};
|