Migrate route paths to the Express 5 path-to-regexp syntax
ProprietaryExpress 5 (and NestJS 11, which runs on it) matches paths with path-to-regexp 8: a wildcard must be named and ? is no longer an optional marker. Rewrites string route paths passed to app and router get, post, put, delete, patch, all, use, route, head and options, to NestJS @Get, @Post, @Put, @Delete, @Patch, @All, @Options and @Head, and to forRoutes: a trailing or whole-segment * becomes *splat (/api/* to /api/*splat), a bare * becomes {*splat} (/{*splat} for Express, so the root still matches), and /:id? becomes {/:id}. Paths with regular expression syntax, groups, other reserved characters or more than one wildcard are left alone, as are paths in arrays and variables. Express applications are variables assigned express() or express.Router() in the same file; the match is by name, not by type. forRoutes('(.*)') on @nestjs/platform-fastify is not migrated.
org. openrewrite. nodejs. migrate. express. MigrateRouteWildcardsmod run . --recipe= org. openrewrite. nodejs. migrate. express. MigrateRouteWildcardsInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.