Description
Did you read the migration guide?
- I have read the whole migration guide
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Potential Commit/PR that introduced the regression
No response
NestJS version
11.x
Describe the regression
This is a regression following the upgrade to version 5 of fastify, the SEARCH method and the new methods implemented need to be registered during the route injection phase (https://fastify.dev/docs/v5.1.x/Guides/Migration-Guide-V5/#removal-of-some-non-standard-http-methods)
instance.route(routeToInjectWithOptions) returns the following error:
FastifyError [Error]: SEARCH method is not supported.
Minimum reproduction code
No response
Input code
No response
Expected behavior
Custom methods should be registered automatically.
Other
I wanted to do a PR, the fix is pretty simple, just check if the method is supported, in the injectRouteOptions function:
if (this.instance.supportedMethods.indexOf(routerMethodKey) > -1) {
this.instance.addHttpMethod(routerMethodKey)
}
But I'm stuck on how to determine if the handler has a @Body decorator to use the hasBody option during the injection:
this.instance.addHttpMethod(routerMethodKey, { hasBody: true })
The other problem is to handle the case of multiple routes that may or may not have a body for the same custom method.