Skip to content

Commit 196a441

Browse files
chore: update migration guide (fastify middleware)
1 parent a88e1de commit 196a441

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

content/faq/global-prefix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ Alternatively, you can specify route as a string (it will apply to every request
2121
app.setGlobalPrefix('v1', { exclude: ['cats'] });
2222
```
2323

24-
> info **Hint** The `path` property supports wildcard parameters using the [path-to-regexp](https://github.com/pillarjs/path-to-regexp#parameters) package. Note: this does not accept wildcard asterisks `*`. Instead, you must use parameters (e.g., `(.*)`, `:splat*`).
24+
> info **Hint** The `path` property supports wildcard parameters using the [path-to-regexp](https://github.com/pillarjs/path-to-regexp#parameters) package. Note: this does not accept wildcard asterisks `*`. Instead, you must use parameters (`:param`) or named wildcards (`*splat`).

content/migration.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,26 @@ bootstrap();
8888

8989
`@nestjs/platform-fastify` v11 now finally supports Fastify v5. This update should be seamless for most users; however, Fastify v5 introduces a few breaking changes, though these are unlikely to affect the majority of NestJS users. For more detailed information, refer to the [Fastify v5 migration guide](https://fastify.dev/docs/v5.1.x/Guides/Migration-Guide-V5/).
9090

91-
> info **Hint** There have been no changes to path matching in Fastify v5, so you can continue using the wildcard syntax as you did before. The behavior remains the same, and routes defined with wildcards (like `*`) will still work as expected.
91+
> info **Hint** There have been no changes to path matching in Fastify v5 (except for middleware, see the section below), so you can continue using the wildcard syntax as you did before. The behavior remains the same, and routes defined with wildcards (like `*`) will still work as expected.
92+
93+
#### Fastify middleware registration
94+
95+
NestJS 11 now uses the latest version of the [path-to-regexp](https://www.npmjs.com/package/path-to-regexp) package to match **middleware paths** in `@nestjs/platform-fastify`. As a result, the `(.*)` syntax for matching all paths is no longer supported. Instead, you should use named wildcards.
96+
97+
For example, if you have a middleware that applies to all routes:
98+
99+
```typescript
100+
// In NestJS 11, this will automatically be converted to a valid route, even if you don't update it.
101+
.forRoutes('(.*)');
102+
```
103+
104+
You'll need to update it to use a named wildcard instead:
105+
106+
```typescript
107+
.forRoutes('*splat');
108+
```
109+
110+
Where `splat` is just an arbitrary name for the wildcard parameter. You can name it anything you like.
92111

93112
#### Module resolution algorithm
94113

@@ -290,9 +309,11 @@ Key changes:
290309

291310
> info **Info** Please note that the `HealthIndicator` and `HealthCheckError` classes have been marked as deprecated and are scheduled for removal in the next major release.
292311
293-
#### Node.js v16 no longer supported
312+
#### Node.js v16 and v18 no longer supported
313+
314+
Starting with NestJS 11, Node.js v16 is no longer supported, as it reached its end-of-life (EOL) on September 11, 2023. Likewise, the security support is scheduled to end on April 30, 2025 for Node.js v18, so we went ahead and dropped support for it as well.
294315

295-
Starting with NestJS 11, Node.js v16 is no longer supported, as it reached its end-of-life (EOL) on September 11, 2023. NestJS 11 now requires **Node.js v20 or higher**.
316+
NestJS 11 now requires **Node.js v20 or higher**.
296317

297318
To ensure the best experience, we strongly recommend using the latest LTS version of Node.js.
298319

content/recipes/async-local-storage.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ export class AppModule implements NestModule {
5959
// to the "als.run" method together with the store.
6060
this.als.run(store, () => next());
6161
})
62-
// and register it for all routes (in case of Fastify use '(.*)')
63-
.forRoutes('*');
62+
.forRoutes('*path');
6463
}
6564
}
6665
@@switch
@@ -89,8 +88,7 @@ export class AppModule {
8988
// to the "als.run" method together with the store.
9089
this.als.run(store, () => next());
9190
})
92-
// and register it for all routes (in case of Fastify use '(.*)')
93-
.forRoutes('*');
91+
.forRoutes('*path');
9492
}
9593
}
9694
```

0 commit comments

Comments
 (0)