-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(fastify): add fastify route constraints #12567
feat(fastify): add fastify route constraints #12567
Conversation
Pull Request Test Coverage Report for Build cbd84d10-1848-4993-bb19-f51e0f22f903
💛 - Coveralls |
import { SetMetadata } from '@nestjs/common'; | ||
import { FASTIFY_ROUTE_CONSTRAINTS_METADATA } from '../constants'; | ||
|
||
type IRouteConstraints = { version?: any; host?: any; [name: string]: any }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we use fastify
types here? it's a hard dep of @nestjs/platform-fastify
package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RouteOptions['constraints']
only defines { [name: string]: any }
, while they explicitly mention version
and host
in the documentation (in addition the custom async constraints).
I will file an issue to Fastify to see if we can use this interface instead.
Update: I submitted fastify/fastify#5097 in case we want to use Fastify types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fastify/fastify#5097 has just been merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will amend my PR once a new version of Fastify is released
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kamilmysliwiec @micalevisk please check now, fastify v4.25.0 has been released with fastify/fastify#5097
df96d74
to
00e0c34
Compare
00e0c34
to
4468928
Compare
…fastify-route-constraints
@Fcmam5 why we're changing the root |
I updated Fastify (as promised in #12567 (comment)) before an earlier PR was merged. I will revert the changes there as it seems to downgrade Please @micalevisk have a look now |
lgtm |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #12496
What is the new behavior?
This adds a new
@RouteConstraints
decorator to specify Fastify route constraintsPoC and Examples:
https://github.com/Fcmam5/fastify-route-constraints-poc#readme
Does this PR introduce a breaking change?
Other information