Skip to content

Conversation

@Mut1aq
Copy link
Contributor

@Mut1aq Mut1aq commented Jan 27, 2025

add names to wildcards for middlewares

Description

In Express 5, wildcards must have names; i18n.module had middleware registeration for all routes, so a name must be used after the "*" character.

Linked Issues

Additional context

add names to wildcards for middlewares
@Mut1aq Mut1aq changed the title Update i18n.module.ts Migrate to Express v5 routes Jan 27, 2025
@msalafia
Copy link

msalafia commented Feb 6, 2025

Any update on this?

@thomasglachant
Copy link

The feature is already working for me, there's just a linter issue to fix to be merged.
@Mut1aq can you fix this?

.apply(I18nMiddleware)
.forRoutes(
isNestMiddleware(consumer) && usingFastify(consumer) ? '(.*)' : '*',
isNestMiddleware(consumer) && usingFastify(consumer) ? '(.*path)' : '*path',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As both Fastify and Express now use the latest path-to-regexp package there's no need to have different formats.

Suggested change
isNestMiddleware(consumer) && usingFastify(consumer) ? '(.*path)' : '*path',
'*path'

@MelanieW97
Copy link

MelanieW97 commented Jun 3, 2025

Migrating to express@5 routes would be wonderful. Looking forward to that.
I've just tried to update to nestjs@11 just to find out that nestjs-i18n breaks my application with nestjs@11.
The issue I got occurs in combination with app.setGlobalPrefix('prefix').

error: Unsupported route path: "/prefix/*". 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.

Someone also opened up an issue regarding my problem right here:
#694 (comment)

@toonvanstrijp
Copy link
Owner

@Mut1aq woud it be possible to check whenever express v5 is used? Currently this would make a breaking change right?

@toonvanstrijp toonvanstrijp merged commit 8a56166 into toonvanstrijp:main Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants