@nestjs/core 10.4.10 → 10.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/core",
3
- "version": "10.4.10",
3
+ "version": "10.4.12",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@core)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -32,11 +32,11 @@
32
32
  "fast-safe-stringify": "2.1.1",
33
33
  "iterare": "1.2.1",
34
34
  "path-to-regexp": "3.3.0",
35
- "tslib": "2.7.0",
35
+ "tslib": "2.8.1",
36
36
  "uid": "2.0.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@nestjs/common": "10.4.10"
39
+ "@nestjs/common": "10.4.12"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@nestjs/common": "^10.0.0",
@@ -0,0 +1,13 @@
1
+ export declare class LegacyRouteConverter {
2
+ private static readonly logger;
3
+ /**
4
+ * Convert legacy routes to the new format (syntax).
5
+ * path-to-regexp used by Express>=v5 and @fastify/middie>=v9 no longer support unnamed wildcards.
6
+ * This method attempts to convert the old syntax to the new one, and logs an error if it fails.
7
+ * @param route The route to convert.
8
+ * @returns The converted route, or the original route if it cannot be converted.
9
+ */
10
+ static tryConvert(route: string): string;
11
+ static printError(route: string): void;
12
+ static printWarning(route: string): void;
13
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LegacyRouteConverter = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const UNSUPPORTED_PATH_MESSAGE = (text, route) => `Unsupported route path: "${route}". In previous versions, the symbols ?, *, and + were used to denote optional or repeating path parameters. The latest version of "path-to-regexp" now requires the use of named parameters. For example, instead of using a route like /users/* to capture all routes starting with "/users", you should use /users/*path. For more details, refer to the migration guide.`;
6
+ class LegacyRouteConverter {
7
+ /**
8
+ * Convert legacy routes to the new format (syntax).
9
+ * path-to-regexp used by Express>=v5 and @fastify/middie>=v9 no longer support unnamed wildcards.
10
+ * This method attempts to convert the old syntax to the new one, and logs an error if it fails.
11
+ * @param route The route to convert.
12
+ * @returns The converted route, or the original route if it cannot be converted.
13
+ */
14
+ static tryConvert(route) {
15
+ // Normalize path to eliminate additional conditions.
16
+ const routeWithLeadingSlash = route.startsWith('/') ? route : `/${route}`;
17
+ const normalizedRoute = route.endsWith('/')
18
+ ? routeWithLeadingSlash
19
+ : `${routeWithLeadingSlash}/`;
20
+ if (normalizedRoute.endsWith('/(.*)/')) {
21
+ // Skip printing warning for the "all" wildcard.
22
+ if (normalizedRoute !== '/(.*)/') {
23
+ this.printWarning(route);
24
+ }
25
+ return route.replace('(.*)', '*path');
26
+ }
27
+ if (normalizedRoute.endsWith('/*/')) {
28
+ // Skip printing warning for the "all" wildcard.
29
+ if (normalizedRoute !== '/*/') {
30
+ this.printWarning(route);
31
+ }
32
+ return route.replace('*', '*path');
33
+ }
34
+ if (normalizedRoute.endsWith('/+/')) {
35
+ this.printWarning(route);
36
+ return route.replace('/+', '/*path');
37
+ }
38
+ return route;
39
+ }
40
+ static printError(route) {
41
+ this.logger.error(UNSUPPORTED_PATH_MESSAGE `${route}`);
42
+ }
43
+ static printWarning(route) {
44
+ this.logger.warn(UNSUPPORTED_PATH_MESSAGE `${route}` + ' Attempting to convert...');
45
+ }
46
+ }
47
+ exports.LegacyRouteConverter = LegacyRouteConverter;
48
+ LegacyRouteConverter.logger = new common_1.Logger(LegacyRouteConverter.name);