@nestjs/core 8.0.11 → 8.2.0
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/CHANGELOG.md +12 -0
- package/index.js +1 -1
- package/injector/injector.d.ts +6 -0
- package/injector/injector.js +49 -5
- package/middleware/middleware-module.js +15 -7
- package/middleware/utils.d.ts +5 -9
- package/middleware/utils.js +16 -18
- package/nest-application.js +3 -0
- package/package.json +2 -2
- package/router/route-path-factory.js +4 -10
- package/router/routes-resolver.js +5 -4
- package/router/utils/exclude-route.util.d.ts +4 -0
- package/router/utils/exclude-route.util.js +18 -0
- package/router/utils/index.d.ts +1 -0
- package/router/utils/index.js +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
<a name="8.2.0"></a>
|
|
7
|
+
# [8.2.0](https://github.com/nestjs/nest/compare/v8.1.2...v8.2.0) (2021-11-08)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @nestjs/core
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.NestFactory = exports.APP_PIPE = exports.APP_INTERCEPTOR = exports.APP_G
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/*
|
|
6
6
|
* Nest @core
|
|
7
|
-
* Copyright(c) 2017 -
|
|
7
|
+
* Copyright(c) 2017 - 2021 Kamil Mysliwiec
|
|
8
8
|
* https://nestjs.com
|
|
9
9
|
* MIT Licensed
|
|
10
10
|
*/
|
package/injector/injector.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface InjectorDependencyContext {
|
|
|
40
40
|
dependencies?: InjectorDependency[];
|
|
41
41
|
}
|
|
42
42
|
export declare class Injector {
|
|
43
|
+
private logger;
|
|
43
44
|
loadPrototype<T>({ token }: InstanceWrapper<T>, collection: Map<InstanceToken, InstanceWrapper<T>>, contextId?: ContextId): void;
|
|
44
45
|
loadInstance<T>(wrapper: InstanceWrapper<T>, collection: Map<InstanceToken, InstanceWrapper>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>;
|
|
45
46
|
loadMiddleware(wrapper: InstanceWrapper, collection: Map<InstanceToken, InstanceWrapper>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>;
|
|
@@ -71,4 +72,9 @@ export declare class Injector {
|
|
|
71
72
|
private isInquirerRequest;
|
|
72
73
|
private isInquirer;
|
|
73
74
|
private addDependencyMetadata;
|
|
75
|
+
private getTokenName;
|
|
76
|
+
private printResolvingDependenciesLog;
|
|
77
|
+
private printLookingForProviderLog;
|
|
78
|
+
private printFoundInModuleLog;
|
|
79
|
+
private isDebugMode;
|
|
74
80
|
}
|
package/injector/injector.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Injector = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
4
5
|
const constants_1 = require("@nestjs/common/constants");
|
|
6
|
+
const cli_colors_util_1 = require("@nestjs/common/utils/cli-colors.util");
|
|
5
7
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
6
8
|
const iterare_1 = require("iterare");
|
|
7
9
|
const runtime_exception_1 = require("../errors/exceptions/runtime.exception");
|
|
@@ -11,6 +13,9 @@ const constants_2 = require("./constants");
|
|
|
11
13
|
const inquirer_1 = require("./inquirer");
|
|
12
14
|
const instance_wrapper_1 = require("./instance-wrapper");
|
|
13
15
|
class Injector {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.logger = new common_1.Logger('InjectorLogger');
|
|
18
|
+
}
|
|
14
19
|
loadPrototype({ token }, collection, contextId = constants_2.STATIC_CONTEXT) {
|
|
15
20
|
if (!collection) {
|
|
16
21
|
return;
|
|
@@ -145,6 +150,8 @@ class Injector {
|
|
|
145
150
|
return param.forwardRef();
|
|
146
151
|
}
|
|
147
152
|
async resolveComponentInstance(moduleRef, token, dependencyContext, wrapper, contextId = constants_2.STATIC_CONTEXT, inquirer, keyOrIndex) {
|
|
153
|
+
this.printResolvingDependenciesLog(token, inquirer);
|
|
154
|
+
this.printLookingForProviderLog(token, moduleRef);
|
|
148
155
|
const providers = moduleRef.providers;
|
|
149
156
|
const instanceWrapper = await this.lookupComponent(providers, moduleRef, Object.assign(Object.assign({}, dependencyContext), { name: token }), wrapper, contextId, inquirer, keyOrIndex);
|
|
150
157
|
return this.resolveComponentHost(moduleRef, instanceWrapper, contextId, inquirer);
|
|
@@ -182,6 +189,7 @@ class Injector {
|
|
|
182
189
|
}
|
|
183
190
|
if (providers.has(name)) {
|
|
184
191
|
const instanceWrapper = providers.get(name);
|
|
192
|
+
this.printFoundInModuleLog(name, moduleRef);
|
|
185
193
|
this.addDependencyMetadata(keyOrIndex, wrapper, instanceWrapper);
|
|
186
194
|
return instanceWrapper;
|
|
187
195
|
}
|
|
@@ -207,6 +215,7 @@ class Injector {
|
|
|
207
215
|
if (moduleRegistry.includes(relatedModule.id)) {
|
|
208
216
|
continue;
|
|
209
217
|
}
|
|
218
|
+
this.printLookingForProviderLog(name, relatedModule);
|
|
210
219
|
moduleRegistry.push(relatedModule.id);
|
|
211
220
|
const { providers, exports } = relatedModule;
|
|
212
221
|
if (!exports.has(name) || !providers.has(name)) {
|
|
@@ -217,6 +226,7 @@ class Injector {
|
|
|
217
226
|
}
|
|
218
227
|
continue;
|
|
219
228
|
}
|
|
229
|
+
this.printFoundInModuleLog(name, relatedModule);
|
|
220
230
|
instanceWrapperRef = providers.get(name);
|
|
221
231
|
this.addDependencyMetadata(keyOrIndex, wrapper, instanceWrapperRef);
|
|
222
232
|
const inquirerId = this.getInquirerId(inquirer);
|
|
@@ -280,11 +290,10 @@ class Injector {
|
|
|
280
290
|
const { metatype, inject } = wrapper;
|
|
281
291
|
const inquirerId = this.getInquirerId(inquirer);
|
|
282
292
|
const instanceHost = targetMetatype.getInstanceByContextId(contextId, inquirerId);
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const isInContext = isStatic || isInRequestScope || isLazyTransient || isExplicitlyRequested;
|
|
293
|
+
const isInContext = wrapper.isStatic(contextId, inquirer) ||
|
|
294
|
+
wrapper.isInRequestScope(contextId, inquirer) ||
|
|
295
|
+
wrapper.isLazyTransient(contextId, inquirer) ||
|
|
296
|
+
wrapper.isExplicitlyRequested(contextId, inquirer);
|
|
288
297
|
if (shared_utils_1.isNil(inject) && isInContext) {
|
|
289
298
|
instanceHost.instance = wrapper.forwardRef
|
|
290
299
|
? Object.assign(instanceHost.instance, new metatype(...instances))
|
|
@@ -351,5 +360,40 @@ class Injector {
|
|
|
351
360
|
? hostWrapper.addPropertiesMetadata(keyOrIndex, instanceWrapper)
|
|
352
361
|
: hostWrapper.addCtorMetadata(keyOrIndex, instanceWrapper);
|
|
353
362
|
}
|
|
363
|
+
getTokenName(token) {
|
|
364
|
+
return shared_utils_1.isFunction(token) ? token.name : token.toString();
|
|
365
|
+
}
|
|
366
|
+
printResolvingDependenciesLog(token, inquirer) {
|
|
367
|
+
var _a;
|
|
368
|
+
if (!this.isDebugMode()) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const tokenName = this.getTokenName(token);
|
|
372
|
+
const dependentName = (_a = inquirer === null || inquirer === void 0 ? void 0 : inquirer.name) !== null && _a !== void 0 ? _a : 'unknown';
|
|
373
|
+
const isAlias = dependentName === tokenName;
|
|
374
|
+
const messageToPrint = `Resolving dependency ${cli_colors_util_1.clc.cyanBright(tokenName)}${cli_colors_util_1.clc.green(' in the ')}${cli_colors_util_1.clc.yellow(dependentName)}${cli_colors_util_1.clc.green(` provider ${isAlias ? '(alias)' : ''}`)}`;
|
|
375
|
+
this.logger.log(messageToPrint);
|
|
376
|
+
}
|
|
377
|
+
printLookingForProviderLog(token, moduleRef) {
|
|
378
|
+
var _a, _b;
|
|
379
|
+
if (!this.isDebugMode()) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const tokenName = this.getTokenName(token);
|
|
383
|
+
const moduleRefName = (_b = (_a = moduleRef === null || moduleRef === void 0 ? void 0 : moduleRef.metatype) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'unknown';
|
|
384
|
+
this.logger.log(`Looking for ${cli_colors_util_1.clc.cyanBright(tokenName)}${cli_colors_util_1.clc.green(' in ')}${cli_colors_util_1.clc.magentaBright(moduleRefName)}`);
|
|
385
|
+
}
|
|
386
|
+
printFoundInModuleLog(token, moduleRef) {
|
|
387
|
+
var _a, _b;
|
|
388
|
+
if (!this.isDebugMode()) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const tokenName = this.getTokenName(token);
|
|
392
|
+
const moduleRefName = (_b = (_a = moduleRef === null || moduleRef === void 0 ? void 0 : moduleRef.metatype) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'unknown';
|
|
393
|
+
this.logger.log(`Found ${cli_colors_util_1.clc.cyanBright(tokenName)}${cli_colors_util_1.clc.green(' in ')}${cli_colors_util_1.clc.magentaBright(moduleRefName)}`);
|
|
394
|
+
}
|
|
395
|
+
isDebugMode() {
|
|
396
|
+
return !!process.env.NEST_DEBUG;
|
|
397
|
+
}
|
|
354
398
|
}
|
|
355
399
|
exports.Injector = Injector;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MiddlewareModule = void 0;
|
|
4
4
|
const request_method_enum_1 = require("@nestjs/common/enums/request-method.enum");
|
|
5
5
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
6
|
+
const utils_1 = require("../router/utils");
|
|
6
7
|
const invalid_middleware_exception_1 = require("../errors/exceptions/invalid-middleware.exception");
|
|
7
8
|
const runtime_exception_1 = require("../errors/exceptions/runtime.exception");
|
|
8
9
|
const context_id_factory_1 = require("../helpers/context-id-factory");
|
|
@@ -14,7 +15,6 @@ const router_proxy_1 = require("../router/router-proxy");
|
|
|
14
15
|
const builder_1 = require("./builder");
|
|
15
16
|
const resolver_1 = require("./resolver");
|
|
16
17
|
const routes_mapper_1 = require("./routes-mapper");
|
|
17
|
-
const utils_1 = require("./utils");
|
|
18
18
|
class MiddlewareModule {
|
|
19
19
|
constructor() {
|
|
20
20
|
this.routerProxy = new router_proxy_1.RouterProxy();
|
|
@@ -133,16 +133,24 @@ class MiddlewareModule {
|
|
|
133
133
|
}
|
|
134
134
|
async registerHandler(applicationRef, method, path, proxy) {
|
|
135
135
|
const prefix = this.config.getGlobalPrefix();
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
const excludedRoutes = this.config.getGlobalPrefixOptions().exclude;
|
|
137
|
+
if (Array.isArray(excludedRoutes) &&
|
|
138
|
+
utils_1.isRouteExcluded(excludedRoutes, path, method)) {
|
|
139
|
+
path = shared_utils_1.addLeadingSlash(path);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const basePath = shared_utils_1.addLeadingSlash(prefix);
|
|
143
|
+
if ((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) && (path === null || path === void 0 ? void 0 : path.startsWith('/'))) {
|
|
144
|
+
// strip slash when a wildcard is being used
|
|
145
|
+
// and global prefix has been set
|
|
146
|
+
path = path === null || path === void 0 ? void 0 : path.slice(1);
|
|
147
|
+
}
|
|
148
|
+
path = basePath + path;
|
|
141
149
|
}
|
|
142
150
|
const isMethodAll = utils_1.isRequestMethodAll(method);
|
|
143
151
|
const requestMethod = request_method_enum_1.RequestMethod[method];
|
|
144
152
|
const router = await applicationRef.createMiddlewareFactory(method);
|
|
145
|
-
router(
|
|
153
|
+
router(path, isMethodAll
|
|
146
154
|
? proxy
|
|
147
155
|
: (req, res, next) => {
|
|
148
156
|
if (applicationRef.getRequestMethod(req) === requestMethod) {
|
package/middleware/utils.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { RequestMethod } from '@nestjs/common';
|
|
2
1
|
import { HttpServer, RouteInfo, Type } from '@nestjs/common/interfaces';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const filterMiddleware: <T extends Function | Type<any> = any>(middleware: T[], excludedRoutes: RouteInfo[], httpAdapter: HttpServer) => Type<any>[];
|
|
8
|
-
export declare const mapToClass: <T extends Function | Type<any>>(middleware: T, excludedRoutes: RouteInfoRegex[], httpAdapter: HttpServer) => Type<any>;
|
|
2
|
+
import { ExcludeRouteMetadata } from '../router/interfaces/exclude-route-metadata.interface';
|
|
3
|
+
export declare const mapToExcludeRoute: (routes: RouteInfo[]) => ExcludeRouteMetadata[];
|
|
4
|
+
export declare const filterMiddleware: <T extends Function | Type<any> = any>(middleware: T[], routes: RouteInfo[], httpAdapter: HttpServer) => Type<any>[];
|
|
5
|
+
export declare const mapToClass: <T extends Function | Type<any>>(middleware: T, excludedRoutes: ExcludeRouteMetadata[], httpAdapter: HttpServer) => Type<any>;
|
|
9
6
|
export declare function isMiddlewareClass(middleware: any): middleware is Type<any>;
|
|
10
7
|
export declare function assignToken(metatype: Type<any>, token?: any): Type<any>;
|
|
11
|
-
export declare function
|
|
12
|
-
export {};
|
|
8
|
+
export declare function isMiddlewareRouteExcluded(req: Record<string, any>, excludedRoutes: ExcludeRouteMetadata[], httpAdapter: HttpServer): boolean;
|
package/middleware/utils.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isMiddlewareRouteExcluded = exports.assignToken = exports.isMiddlewareClass = exports.mapToClass = exports.filterMiddleware = exports.mapToExcludeRoute = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
6
6
|
const iterare_1 = require("iterare");
|
|
7
7
|
const pathToRegexp = require("path-to-regexp");
|
|
8
8
|
const uuid_1 = require("uuid");
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const utils_1 = require("../router/utils");
|
|
10
|
+
const mapToExcludeRoute = (routes) => {
|
|
11
|
+
return routes.map(({ path, method }) => ({
|
|
12
|
+
pathRegex: pathToRegexp(path),
|
|
13
|
+
requestMethod: method,
|
|
14
|
+
}));
|
|
11
15
|
};
|
|
12
|
-
exports.
|
|
13
|
-
const filterMiddleware = (middleware,
|
|
14
|
-
const
|
|
16
|
+
exports.mapToExcludeRoute = mapToExcludeRoute;
|
|
17
|
+
const filterMiddleware = (middleware, routes, httpAdapter) => {
|
|
18
|
+
const excludedRoutes = exports.mapToExcludeRoute(routes);
|
|
15
19
|
return iterare_1.iterate([])
|
|
16
20
|
.concat(middleware)
|
|
17
21
|
.filter(shared_utils_1.isFunction)
|
|
18
|
-
.map((item) => exports.mapToClass(item,
|
|
22
|
+
.map((item) => exports.mapToClass(item, excludedRoutes, httpAdapter))
|
|
19
23
|
.toArray();
|
|
20
24
|
};
|
|
21
25
|
exports.filterMiddleware = filterMiddleware;
|
|
@@ -27,7 +31,7 @@ const mapToClass = (middleware, excludedRoutes, httpAdapter) => {
|
|
|
27
31
|
const MiddlewareHost = class extends middleware {
|
|
28
32
|
use(...params) {
|
|
29
33
|
const [req, _, next] = params;
|
|
30
|
-
const isExcluded =
|
|
34
|
+
const isExcluded = isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter);
|
|
31
35
|
if (isExcluded) {
|
|
32
36
|
return next();
|
|
33
37
|
}
|
|
@@ -40,7 +44,7 @@ const mapToClass = (middleware, excludedRoutes, httpAdapter) => {
|
|
|
40
44
|
constructor() {
|
|
41
45
|
this.use = (...params) => {
|
|
42
46
|
const [req, _, next] = params;
|
|
43
|
-
const isExcluded =
|
|
47
|
+
const isExcluded = isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter);
|
|
44
48
|
if (isExcluded) {
|
|
45
49
|
return next();
|
|
46
50
|
}
|
|
@@ -67,7 +71,7 @@ function assignToken(metatype, token = uuid_1.v4()) {
|
|
|
67
71
|
return metatype;
|
|
68
72
|
}
|
|
69
73
|
exports.assignToken = assignToken;
|
|
70
|
-
function
|
|
74
|
+
function isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter) {
|
|
71
75
|
if (excludedRoutes.length <= 0) {
|
|
72
76
|
return false;
|
|
73
77
|
}
|
|
@@ -77,12 +81,6 @@ function isRouteExcluded(req, excludedRoutes, httpAdapter) {
|
|
|
77
81
|
const pathname = queryParamsIndex >= 0
|
|
78
82
|
? originalUrl.slice(0, queryParamsIndex)
|
|
79
83
|
: originalUrl;
|
|
80
|
-
|
|
81
|
-
if (exports.isRequestMethodAll(method) || common_1.RequestMethod[method] === reqMethod) {
|
|
82
|
-
return regex.exec(pathname);
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
});
|
|
86
|
-
return isExcluded;
|
|
84
|
+
return utils_1.isRouteExcluded(excludedRoutes, pathname, common_1.RequestMethod[reqMethod]);
|
|
87
85
|
}
|
|
88
|
-
exports.
|
|
86
|
+
exports.isMiddlewareRouteExcluded = isMiddlewareRouteExcluded;
|
package/nest-application.js
CHANGED
|
@@ -170,6 +170,9 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
|
|
|
170
170
|
if ((_b = (_a = this.appOptions) === null || _a === void 0 ? void 0 : _a.autoFlushLogs) !== null && _b !== void 0 ? _b : true) {
|
|
171
171
|
this.flushLogs();
|
|
172
172
|
}
|
|
173
|
+
if (originalCallbackArgs[0] instanceof Error) {
|
|
174
|
+
return reject(originalCallbackArgs[0]);
|
|
175
|
+
}
|
|
173
176
|
const address = this.httpServer.address();
|
|
174
177
|
if (address) {
|
|
175
178
|
this.httpServer.removeListener('error', errorHandler);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.2.0",
|
|
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": "8.0
|
|
39
|
+
"@nestjs/common": "8.2.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^8.0.0",
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RoutePathFactory = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
6
7
|
class RoutePathFactory {
|
|
7
8
|
constructor(applicationConfig) {
|
|
8
9
|
this.applicationConfig = applicationConfig;
|
|
@@ -71,16 +72,9 @@ class RoutePathFactory {
|
|
|
71
72
|
return false;
|
|
72
73
|
}
|
|
73
74
|
const options = this.applicationConfig.getGlobalPrefixOptions();
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return options.exclude.some(route => {
|
|
78
|
-
if (!route.pathRegex.exec(path)) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
return (route.requestMethod === common_1.RequestMethod.ALL ||
|
|
82
|
-
route.requestMethod === requestMethod);
|
|
83
|
-
});
|
|
75
|
+
const excludedRoutes = options.exclude;
|
|
76
|
+
return (Array.isArray(excludedRoutes) &&
|
|
77
|
+
utils_1.isRouteExcluded(excludedRoutes, path, requestMethod));
|
|
84
78
|
}
|
|
85
79
|
}
|
|
86
80
|
exports.RoutePathFactory = RoutePathFactory;
|
|
@@ -108,10 +108,11 @@ class RoutesResolver {
|
|
|
108
108
|
return Reflect.getMetadata(constants_1.HOST_METADATA, metatype);
|
|
109
109
|
}
|
|
110
110
|
getVersionMetadata(metatype) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
:
|
|
111
|
+
var _a;
|
|
112
|
+
const versioningConfig = this.applicationConfig.getVersioning();
|
|
113
|
+
if (versioningConfig) {
|
|
114
|
+
return ((_a = Reflect.getMetadata(constants_1.VERSION_METADATA, metatype)) !== null && _a !== void 0 ? _a : versioningConfig.defaultVersion);
|
|
115
|
+
}
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
exports.RoutesResolver = RoutesResolver;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RequestMethod } from '@nestjs/common';
|
|
2
|
+
import { ExcludeRouteMetadata } from '../interfaces/exclude-route-metadata.interface';
|
|
3
|
+
export declare const isRequestMethodAll: (method: RequestMethod) => boolean;
|
|
4
|
+
export declare function isRouteExcluded(excludedRoutes: ExcludeRouteMetadata[], path: string, requestMethod?: RequestMethod): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRouteExcluded = exports.isRequestMethodAll = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const isRequestMethodAll = (method) => {
|
|
6
|
+
return common_1.RequestMethod.ALL === method || method === -1;
|
|
7
|
+
};
|
|
8
|
+
exports.isRequestMethodAll = isRequestMethodAll;
|
|
9
|
+
function isRouteExcluded(excludedRoutes, path, requestMethod) {
|
|
10
|
+
return excludedRoutes.some(route => {
|
|
11
|
+
if (exports.isRequestMethodAll(route.requestMethod) ||
|
|
12
|
+
route.requestMethod === requestMethod) {
|
|
13
|
+
return route.pathRegex.exec(path);
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.isRouteExcluded = isRouteExcluded;
|
package/router/utils/index.d.ts
CHANGED
package/router/utils/index.js
CHANGED