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 type for http options #13869

Conversation

stefanvanderwolf
Copy link
Contributor

@stefanvanderwolf stefanvanderwolf commented Aug 8, 2024

Fastify has support for http options through the fastify function call which was not officially included in the nest adapter. Currently passing an object with a http field works, but gives the developer no type hinting about the http field.

First time open source contributor so please let me know what is not correct.

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?

Currently creating an http server we cannot pass any http options without fooling the typescript type system. So this works, but in my opinion more magical than explicit.

const serverOptions: ServerOptions = {
  // Increase max header size from default ~16kb
  maxHeaderSize: 32768,
};
const options = {
  logger: undefined,
  http: serverOptions,
};

const adapter = new FastifyAdapter(options);

I use a property from the type FastifyServerOptions so it makes Typescript happy but also pass another property called http which will be used by fastify to create a server.

What is the new behavior?

With addition of the new type you can now do this (likewise the https property):

new FastifyAdapter({
  http: {
    maxHeaderSize: 32768
  }
})

Does this PR introduce a breaking change?

  • Yes
  • No

Fastify has support for http options through the fastify function call
which was not officially included in the nest adapter. Currently passing
an object with a http field works, but gives the developer no type
hinting about the `http` field.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 5791696f-68b2-48f0-8ee9-00b07c386819

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.208%

Totals Coverage Status
Change from base Build 875294d7-6fa4-40f6-9340-1a6d68f34376: 0.0%
Covered Lines: 6745
Relevant Lines: 7315

💛 - Coveralls

@kamilmysliwiec
Copy link
Member

LGTM

@kamilmysliwiec kamilmysliwiec merged commit dc9df54 into nestjs:master Aug 12, 2024
3 checks passed
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.

3 participants