MCPcopy
hub / github.com/nestjs/nest / mapToExcludeRoute

Function mapToExcludeRoute

packages/core/middleware/utils.ts:15–42  ·  view source on GitHub ↗
(
  routes: (string | RouteInfo)[],
)

Source from the content-addressed store, hash-verified

13import { isRouteExcluded } from '../router/utils';
14
15export const mapToExcludeRoute = (
16 routes: (string | RouteInfo)[],
17): ExcludeRouteMetadata[] => {
18 return routes.map(route => {
19 const originalPath = isString(route) ? route : route.path;
20 const path = LegacyRouteConverter.tryConvert(originalPath);
21
22 try {
23 if (isString(route)) {
24 return {
25 path,
26 requestMethod: RequestMethod.ALL,
27 pathRegex: pathToRegexp(addLeadingSlash(path)).regexp,
28 };
29 }
30 return {
31 path,
32 requestMethod: route.method,
33 pathRegex: pathToRegexp(addLeadingSlash(path)).regexp,
34 };
35 } catch (e) {
36 if (e instanceof TypeError) {
37 LegacyRouteConverter.printError(originalPath);
38 }
39 throw e;
40 }
41 });
42};
43
44export const filterMiddleware = <T extends Function | Type<any> = any>(
45 middleware: T[],

Callers 5

setGlobalPrefixMethod · 0.90
utils.spec.tsFile · 0.90
filterMiddlewareFunction · 0.85

Calls 4

isStringFunction · 0.90
addLeadingSlashFunction · 0.90
tryConvertMethod · 0.80
printErrorMethod · 0.80

Tested by

no test coverage detected