Skip to content

feat(scan): support QUERY method suffix for file-based routes - #4594

Merged
pi0 merged 1 commit into
mainfrom
feat/query
Sep 7, 2026
Merged

pi0 merged 1 commit into
mainfrom
feat/query

Conversation

@pi0x

@pi0x pi0x commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Adds the QUERY method — a safe, idempotent alternative to GET that carries a request body — to file-based route scanning.

Changes

  • src/scan.ts: added query to the filename method-suffix regex and MatchedMethodSuffix, so routes/search.query.ts registers as a QUERY-only route (and composes with the env suffixes, e.g. search.query.prod.ts).
  • docs/1.docs/5.routing.md: listed query among the supported suffixes, with a note that proxy/CDN/platform support for the verb is still uneven.
  • Regression test: test/fixture/server/routes/api/methods/search.query.ts + search.get.ts, and a case in test/tests.ts asserting a QUERY request reaches the .query handler while GET on the same path still reaches the .get one. It fails on the unpatched scanner (404) and passes after.
  • Two Vercel inline snapshots updated for the new fixture route.

Notes

This is the only Nitro-side change needed — everything downstream is already method-agnostic. src/routing.ts and src/build/virtual/routing.ts pass the method through as an opaque string, and rou3 uppercases it at match time. h3 v2 (rc.31, already pinned) has QUERY in both its HTTPMethod type and its HTTP_METHODS set, so defineHandler/config handlers with method: "QUERY", the app.query() shorthand, and method-scoped route rules like "QUERY /api/**" worked already.

The Azure Functions httpTrigger method list in src/presets/azure/utils.ts was left alone — it is a platform-supported list that already omits connect/trace.

Unrelated pre-existing wrinkle spotted while working on this, not addressed here: NitroEventHandler.method is typed as h3's HTTPMethod (uppercase only), while the scanner produces lowercase and docs/3.config documents method: "post". A config handler written as method: "query" (or "post") is a type error today even though it works at runtime.

Verification

pnpm lint, pnpm typecheck, pnpm test:rollup and pnpm test:rolldown all pass (1073 tests each). The new test passes on every preset covered by testNitro, including cloudflare/miniflare, aws-lambda, netlify, deno, bun and winterjs.

🤖 Generated with AI assistant

Adds `query` to the recognized method suffixes so `routes/search.query.ts`
registers a QUERY-only route. h3 v2 already supports the verb end to end.
@pi0x
pi0x requested a review from pi0 as a code owner September 7, 2026 21:54
@vercel

vercel Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nitro.build Ready Ready Preview Sep 7, 2026 9:54pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 3fd7df92-dfab-415f-b73f-605ba5d7843a

📥 Commits

Reviewing files that changed from the base of the PR and between 4b7b46b and 92cbf38.

📒 Files selected for processing (6)
  • docs/1.docs/5.routing.md
  • src/scan.ts
  • test/fixture/server/routes/api/methods/search.get.ts
  • test/fixture/server/routes/api/methods/search.query.ts
  • test/presets/vercel.test.ts
  • test/tests.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The scanner now recognizes .query as a filename-based HTTP method suffix. Route fixtures, runtime tests, Vercel snapshots, and routing documentation cover QUERY and GET handling.

Changes

QUERY method routing

Layer / File(s) Summary
QUERY suffix recognition and validation
src/scan.ts, test/fixture/server/routes/api/methods/*, test/tests.ts, test/presets/vercel.test.ts, docs/1.docs/5.routing.md
The scanner recognizes .query suffixes. Fixtures define QUERY and GET handlers. Tests validate QUERY and GET responses. Vercel snapshots include the generated route. Documentation describes QUERY support and fallback guidance.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 92cbf

This adds file-based QUERY route support while preserving GET handling for the same path. The implementation, documentation, and regression coverage are aligned, with no current merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits format with the type feat, scope scan, and a clear summary of the QUERY method suffix change.
Description check ✅ Passed The description directly explains the scanner change, documentation updates, regression tests, snapshot updates, and verification results.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/query

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4594

commit: 92cbf38

@pi0
pi0 merged commit bba7350 into main Sep 7, 2026
13 of 14 checks passed
@pi0
pi0 deleted the feat/query branch September 7, 2026 21:56

This branch was successfully deployed

1 active deployment
Preview — 92cbf385 Deployed Sep 7, 2026 by vercel[bot]
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.

2 participants