@nestjs/core 10.3.2 → 10.3.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.
package/middleware/builder.js
CHANGED
|
@@ -34,10 +34,15 @@ MiddlewareBuilder.ConfigProxy = class {
|
|
|
34
34
|
return this.excludedRoutes;
|
|
35
35
|
}
|
|
36
36
|
exclude(...routes) {
|
|
37
|
-
this.excludedRoutes = this.getRoutesFlatList(routes).
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
this.excludedRoutes = this.getRoutesFlatList(routes).reduce((excludedRoutes, route) => {
|
|
38
|
+
for (const routePath of this.routeInfoPathExtractor.extractPathFrom(route)) {
|
|
39
|
+
excludedRoutes.push({
|
|
40
|
+
...route,
|
|
41
|
+
path: routePath,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return excludedRoutes;
|
|
45
|
+
}, []);
|
|
41
46
|
return this;
|
|
42
47
|
}
|
|
43
48
|
forRoutes(...routes) {
|
|
@@ -2,14 +2,14 @@ import { RouteInfo } from '@nestjs/common/interfaces';
|
|
|
2
2
|
import { ApplicationConfig } from '../application-config';
|
|
3
3
|
export declare class RouteInfoPathExtractor {
|
|
4
4
|
private readonly applicationConfig;
|
|
5
|
-
private routePathFactory;
|
|
5
|
+
private readonly routePathFactory;
|
|
6
6
|
private readonly prefixPath;
|
|
7
7
|
private readonly excludedGlobalPrefixRoutes;
|
|
8
8
|
private readonly versioningConfig?;
|
|
9
9
|
constructor(applicationConfig: ApplicationConfig);
|
|
10
10
|
extractPathsFrom({ path, method, version }: RouteInfo): string[];
|
|
11
|
-
extractPathFrom(route: RouteInfo): string;
|
|
11
|
+
extractPathFrom(route: RouteInfo): string[];
|
|
12
12
|
private isAWildcard;
|
|
13
|
-
private
|
|
13
|
+
private extractNonWildcardPathsFrom;
|
|
14
14
|
private extractVersionPathFrom;
|
|
15
15
|
}
|
|
@@ -15,39 +15,51 @@ class RouteInfoPathExtractor {
|
|
|
15
15
|
this.versioningConfig = this.applicationConfig.getVersioning();
|
|
16
16
|
}
|
|
17
17
|
extractPathsFrom({ path, method, version }) {
|
|
18
|
-
const
|
|
18
|
+
const versionPaths = this.extractVersionPathFrom(version);
|
|
19
19
|
if (this.isAWildcard(path)) {
|
|
20
|
+
const entries = versionPaths.length > 0
|
|
21
|
+
? versionPaths.map(versionPath => this.prefixPath + versionPath + (0, shared_utils_1.addLeadingSlash)(path))
|
|
22
|
+
: [this.prefixPath + (0, shared_utils_1.addLeadingSlash)(path)];
|
|
20
23
|
return Array.isArray(this.excludedGlobalPrefixRoutes)
|
|
21
24
|
? [
|
|
22
|
-
|
|
23
|
-
...this.excludedGlobalPrefixRoutes.map(route =>
|
|
25
|
+
...entries,
|
|
26
|
+
...this.excludedGlobalPrefixRoutes.map(route => versionPaths + (0, shared_utils_1.addLeadingSlash)(route.path)),
|
|
24
27
|
]
|
|
25
|
-
:
|
|
28
|
+
: entries;
|
|
26
29
|
}
|
|
27
|
-
return
|
|
30
|
+
return this.extractNonWildcardPathsFrom({ path, method, version });
|
|
28
31
|
}
|
|
29
32
|
extractPathFrom(route) {
|
|
30
33
|
if (this.isAWildcard(route.path) && !route.version) {
|
|
31
|
-
return (0, shared_utils_1.addLeadingSlash)(route.path);
|
|
34
|
+
return [(0, shared_utils_1.addLeadingSlash)(route.path)];
|
|
32
35
|
}
|
|
33
|
-
return this.
|
|
36
|
+
return this.extractNonWildcardPathsFrom(route);
|
|
34
37
|
}
|
|
35
38
|
isAWildcard(path) {
|
|
36
39
|
return ['*', '/*', '/*/', '(.*)', '/(.*)'].includes(path);
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
const
|
|
41
|
+
extractNonWildcardPathsFrom({ path, method, version, }) {
|
|
42
|
+
const versionPaths = this.extractVersionPathFrom(version);
|
|
40
43
|
if (Array.isArray(this.excludedGlobalPrefixRoutes) &&
|
|
41
44
|
(0, utils_1.isRouteExcluded)(this.excludedGlobalPrefixRoutes, path, method)) {
|
|
42
|
-
|
|
45
|
+
if (!versionPaths.length) {
|
|
46
|
+
return [(0, shared_utils_1.addLeadingSlash)(path)];
|
|
47
|
+
}
|
|
48
|
+
return versionPaths.map(versionPath => versionPath + (0, shared_utils_1.addLeadingSlash)(path));
|
|
43
49
|
}
|
|
44
|
-
|
|
50
|
+
if (!versionPaths.length) {
|
|
51
|
+
return [this.prefixPath + (0, shared_utils_1.addLeadingSlash)(path)];
|
|
52
|
+
}
|
|
53
|
+
return versionPaths.map(versionPath => this.prefixPath + versionPath + (0, shared_utils_1.addLeadingSlash)(path));
|
|
45
54
|
}
|
|
46
|
-
extractVersionPathFrom(
|
|
47
|
-
if (!
|
|
48
|
-
return
|
|
55
|
+
extractVersionPathFrom(versionValue) {
|
|
56
|
+
if (!versionValue || this.versioningConfig?.type !== common_1.VersioningType.URI)
|
|
57
|
+
return [];
|
|
49
58
|
const versionPrefix = this.routePathFactory.getVersionPrefix(this.versioningConfig);
|
|
50
|
-
|
|
59
|
+
if (Array.isArray(versionValue)) {
|
|
60
|
+
return versionValue.map(version => (0, shared_utils_1.addLeadingSlash)(versionPrefix + version.toString()));
|
|
61
|
+
}
|
|
62
|
+
return [(0, shared_utils_1.addLeadingSlash)(versionPrefix + versionValue.toString())];
|
|
51
63
|
}
|
|
52
64
|
}
|
|
53
65
|
exports.RouteInfoPathExtractor = RouteInfoPathExtractor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.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
|
"uid": "2.0.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nestjs/common": "10.3.
|
|
39
|
+
"@nestjs/common": "10.3.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^10.0.0",
|