This commit is contained in:
Kamil Myśliwiec
2023-02-01 14:29:21 +01:00
parent 2924c03aa3
commit c1815d2f8c
2 changed files with 6 additions and 9 deletions

View File

@@ -15,7 +15,7 @@ scalar Date
type Query {
recipe(id: String!): Recipe!
recipes(skip: Int = 0, take: Int = 25): [Recipe!]!
recipes(skip: Int! = 0, take: Int! = 25): [Recipe!]!
}
type Mutation {

View File

@@ -316,10 +316,11 @@ export class MiddlewareModule<
) {
const prefix = this.config.getGlobalPrefix();
const excludedRoutes = this.config.getGlobalPrefixOptions().exclude;
const isAWildcard = ['*', '/*', '(.*)', '/(.*)'].includes(path);
if (
Array.isArray(excludedRoutes) &&
isRouteExcluded(excludedRoutes, path, method)
(Array.isArray(excludedRoutes) &&
isRouteExcluded(excludedRoutes, path, method)) ||
isAWildcard
) {
path = addLeadingSlash(path);
} else {
@@ -343,6 +344,7 @@ export class MiddlewareModule<
const isMethodAll = isRequestMethodAll(method);
const requestMethod = RequestMethod[method];
const router = await applicationRef.createMiddlewareFactory(method);
const middlewareFunction = isMethodAll
? proxy
: <TRequest, TResponse>(
@@ -356,11 +358,6 @@ export class MiddlewareModule<
return next();
};
const isAWildcard = ['*', '/*', '(.*)', '/(.*)'].includes(path);
if (isAWildcard && Array.isArray(excludedRoutes)) {
excludedRoutes.forEach(route => router(route.path, middlewareFunction));
}
router(path, middlewareFunction);
}