Skip to content

feat(router): add support for the QUERY HTTP method - #140

Open
DavideCarvalho wants to merge 1 commit into
adonisjs:9.xfrom
DavideCarvalho:feat/query-http-method
Open

feat(router): add support for the QUERY HTTP method#140
DavideCarvalho wants to merge 1 commit into
adonisjs:9.xfrom
DavideCarvalho:feat/query-http-method

Conversation

@DavideCarvalho

Copy link
Copy Markdown

What

Adds first-class support for the QUERY HTTP method — the safe, idempotent method with a request body designed for complex queries that don't fit in a URL.

  • router.query(pattern, handler) shorthand, following the exact same pattern as router.get/post/put/patch/delete
  • urlFor.query() on the URL builder (runtime + type definitions in client/types.ts)
  • signedUrlFor.query() on the signed URL builder

router.any() was intentionally left unchanged to avoid altering the behavior of existing routes.

Why

Node.js parses the QUERY method out of the box on every version covered by this package's engines range (>=24.0.0 — llhttp has shipped it since before v24.0.0, verified against deps/llhttp at the v24.0.0 tag), so routes defined with router.route(pattern, ['QUERY'], handler) already work today. This PR just gives it the same ergonomic, type-safe surface as the other verbs.

Tests

  • router.query() route definition with string controller and controller-tuple handlers
  • urlFor.query() and signedUrlFor.query() coverage in the existing method-specific builder tests
  • An end-to-end test that boots a real node:http server and dispatches a fetch(url, { method: 'QUERY', body: ... }) request through the router

npm test (lint + 641 tests), npm run typecheck and npm run build all pass.

🤖 Generated with Claude Code

Adds a router.query() shorthand for defining routes that respond to
the QUERY HTTP method (draft-ietf-httpbis-safe-method-w-body), along
with urlFor.query() and signedUrlFor.query() builders for parity with
the other verb-specific helpers.

Node.js supports the QUERY method since llhttp shipped it, which is
included in every version covered by the engines range (>=24.0.0).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant