Skip to content

types: support single HTTPMethods string and export defaults - #499

Merged
Tony133 merged 2 commits into
fastify:mainfrom
abdul-karim-mia:fix/types-http-methods-and-defaults
Nov 25, 2026
Merged

Tony133 merged 2 commits into
fastify:mainfrom
abdul-karim-mia:fix/types-http-methods-and-defaults

Conversation

@abdul-karim-mia

Copy link
Copy Markdown
Contributor

Description

This PR updates the TypeScript definitions in @fastify/http-proxy to align with the runtime implementation and export definitions:

  1. Allow single HTTPMethods string in httpMethods option:
    • The runtime supports both a single method string (opts.httpMethods: 'GET') and an array of methods (opts.httpMethods: ['GET', 'POST']) via [].concat(method) and is tested in test/existing-routes.js.
    • Updated FastifyHttpProxyOptions.httpMethods from string[] to HTTPMethods | HTTPMethods[] using HTTPMethods from fastify.
  2. Export defaultRoutes and defaultHttpMethods:
    • index.js exports module.exports.defaultRoutes = defaultRoutes and module.exports.defaultHttpMethods = defaultHttpMethods.
    • Exposed them as named exports and properties on FastifyHttpProxy.
  3. TypeScript test coverage:
    • Added test assertions for single string httpMethods: 'GET', defaultRoutes, and defaultHttpMethods in types/index.tst.ts.

Checklist

  • Code conforms to project conventions and ESLint rules (npm run lint).
  • All unit and integration tests passing (174/174 pass with 100% code coverage).
  • TypeScript types verify cleanly (npm run typescript, 44/44 assertions passing).
  • Pure LF line endings and DCO sign-off.

Signed-off-by: Abdul karim mia <akmia51@gmail.com>

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm.

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@Tony133 Tony133 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@Tony133
Tony133 merged commit 38de7e5 into fastify:main Nov 25, 2026
19 checks passed
@abdul-karim-mia
abdul-karim-mia deleted the fix/types-http-methods-and-defaults branch November 25, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants