( routes: (string | RouteInfo)[], )
| 13 | import { isRouteExcluded } from '../router/utils'; |
| 14 | |
| 15 | export 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 | |
| 44 | export const filterMiddleware = <T extends Function | Type<any> = any>( |
| 45 | middleware: T[], |
no test coverage detected