1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.transformPatternToRoute = void 0;
|
4 | const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | function transformPatternToRoute(pattern) {
|
18 | if ((0, shared_utils_1.isString)(pattern) || (0, shared_utils_1.isNumber)(pattern)) {
|
19 | return `${pattern}`;
|
20 | }
|
21 | if (!(0, shared_utils_1.isObject)(pattern)) {
|
22 | return pattern;
|
23 | }
|
24 | const sortedKeys = Object.keys(pattern).sort((a, b) => ('' + a).localeCompare(b));
|
25 |
|
26 | const sortedPatternParams = sortedKeys.map(key => {
|
27 | let partialRoute = `"${key}":`;
|
28 | partialRoute += (0, shared_utils_1.isString)(pattern[key])
|
29 | ? `"${transformPatternToRoute(pattern[key])}"`
|
30 | : transformPatternToRoute(pattern[key]);
|
31 | return partialRoute;
|
32 | });
|
33 | const route = sortedPatternParams.join(',');
|
34 | return `{${route}}`;
|
35 | }
|
36 | exports.transformPatternToRoute = transformPatternToRoute;
|