UNPKG

1.01 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.flattenRoutePaths = void 0;
4const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5function flattenRoutePaths(routes) {
6 const result = [];
7 routes.forEach(item => {
8 if (item.module && item.path) {
9 result.push({ module: item.module, path: item.path });
10 }
11 if (item.children) {
12 const childrenRef = item.children;
13 childrenRef.forEach(child => {
14 if (typeof child !== 'string' && child.path) {
15 child.path = shared_utils_1.normalizePath(shared_utils_1.normalizePath(item.path) + shared_utils_1.normalizePath(child.path));
16 }
17 else {
18 result.push({ path: item.path, module: child });
19 }
20 });
21 result.push(...flattenRoutePaths(childrenRef));
22 }
23 });
24 return result;
25}
26exports.flattenRoutePaths = flattenRoutePaths;