Skip to content
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

Merged

Conversation

Fcmam5
Copy link
Contributor

@Fcmam5 Fcmam5 commented Oct 14, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #12496

What is the new behavior?

This adds a new @RouteConstraints decorator to specify Fastify route constraints

PoC and Examples:

https://github.com/Fcmam5/fastify-route-constraints-poc#readme

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@Fcmam5 Fcmam5 closed this Oct 14, 2023
@Fcmam5 Fcmam5 deleted the feature/fastify-route-constraints branch October 14, 2023 15:13
@Fcmam5 Fcmam5 restored the feature/fastify-route-constraints branch October 14, 2023 15:13
@coveralls
Copy link

coveralls commented Oct 14, 2023

Pull Request Test Coverage Report for Build cbd84d10-1848-4993-bb19-f51e0f22f903

  • 5 of 5 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 92.263%

Totals Coverage Status
Change from base Build b9656fc4-29de-4d04-bfe4-e42d2bcb8d77: 0.005%
Covered Lines: 6702
Relevant Lines: 7264

💛 - Coveralls

@Fcmam5 Fcmam5 reopened this Oct 14, 2023
import { SetMetadata } from '@nestjs/common';
import { FASTIFY_ROUTE_CONSTRAINTS_METADATA } from '../constants';

type IRouteConstraints = { version?: any; host?: any; [name: string]: any };
Copy link
Member

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

Copy link
Contributor Author

@Fcmam5 Fcmam5 Oct 14, 2023

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

Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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

@Fcmam5 Fcmam5 force-pushed the feature/fastify-route-constraints branch from df96d74 to 00e0c34 Compare December 13, 2023 21:22
@micalevisk
Copy link
Member

micalevisk commented Dec 17, 2023

@Fcmam5 why we're changing the root package-lock.json file? 🤔

@Fcmam5
Copy link
Contributor Author

Fcmam5 commented Dec 18, 2023

@Fcmam5 why we're changing the root package-lock.json file? 🤔

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 pino.

Please @micalevisk have a look now

@kamilmysliwiec kamilmysliwiec merged commit 202dfbf into nestjs:master Dec 18, 2023
3 checks passed
@kamilmysliwiec
Copy link
Member

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants