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): supporting fastify route config #11992

Merged
merged 2 commits into from
Aug 18, 2023

Conversation

rich-w-lee
Copy link
Contributor

@rich-w-lee rich-w-lee commented Jul 7, 2023

Resolves #11815

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: #11815

What is the new behavior?

Users can use the @RouteConfig() decorator to specify a value for the route config for fastify endpoints

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commented Jul 7, 2023

Pull Request Test Coverage Report for Build f42754e6-8e3c-4930-98b6-09e98c21196b

  • 8 of 8 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.009%) to 92.756%

Totals Coverage Status
Change from base Build 352ed093-fa75-4b36-b8fb-bac61dbb5219: 0.009%
Covered Lines: 6402
Relevant Lines: 6902

💛 - Coveralls

@rich-w-lee
Copy link
Contributor Author

Docs PR: nestjs/docs.nestjs.com#2790

@rich-w-lee
Copy link
Contributor Author

Note: there wasn't an existing test case for applyCallbackToRouter, so I didn't create a new test for that. Similarly there isn't a test file for fastify-adapter.ts, so I also excluded writing a test for that. If needed, I can add a test case/file and the relevant tests for the new code

@kamilmysliwiec
Copy link
Member

Could you create a draft PR to the docs describing this feature? :) A short section just for demonstration purposes would be sufficient

@rich-w-lee rich-w-lee force-pushed the feature/fastify-route-config branch from 361c208 to 81ce478 Compare July 17, 2023 21:58
@rich-w-lee
Copy link
Contributor Author

Could you create a draft PR to the docs describing this feature? :) A short section just for demonstration purposes would be sufficient

Is the change in this PR good or do you want me to elaborate? https://github.com/nestjs/docs.nestjs.com/pull/2790/files

@kamilmysliwiec
Copy link
Member

@rich-w-lee ahh I must have missed that PR, apologies! Looks good

import { SetMetadata } from '@nestjs/common';
import { FASTIFY_ROUTE_CONFIG_METADATA } from '../constants';

export const RouteConfig = (config: 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 we get ride of the any here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I checked in the fastify types, and they don't have a type requirement for it, so I want to check what you prefer instead of any:

  1. Using unknown since it's defined by the client
  2. Using a generic

Copy link
Member

@micalevisk micalevisk Aug 8, 2023

Choose a reason for hiding this comment

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

to me, generic type arg is almost the same as having any in terms of type safety

unknown would be better but cumbersome to maintain

so we can keep any until they release a type for that config.

But we can have a jsdocs on that like this:

/**
 * @param config See {@link https://fastify.dev/docs/latest/Reference/Routes/#config}
 */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, I can add that in 👍

@kamilmysliwiec kamilmysliwiec merged commit d368d33 into nestjs:master Aug 18, 2023
4 checks passed
@kamilmysliwiec
Copy link
Member

lgtm

@rich-w-lee rich-w-lee deleted the feature/fastify-route-config branch August 22, 2023 13:26
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.

Supporting Fastify Route Config
4 participants