Repository navigation
feat(scan): support QUERY method suffix for file-based routes - #4594
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe scanner now recognizes ChangesQUERY method routing
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to 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)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation 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.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
commit: |
Adds the
QUERYmethod — a safe, idempotent alternative toGETthat carries a request body — to file-based route scanning.Changes
src/scan.ts: addedqueryto the filename method-suffix regex andMatchedMethodSuffix, soroutes/search.query.tsregisters as aQUERY-only route (and composes with the env suffixes, e.g.search.query.prod.ts).docs/1.docs/5.routing.md: listedqueryamong the supported suffixes, with a note that proxy/CDN/platform support for the verb is still uneven.test/fixture/server/routes/api/methods/search.query.ts+search.get.ts, and a case intest/tests.tsasserting aQUERYrequest reaches the.queryhandler whileGETon the same path still reaches the.getone. It fails on the unpatched scanner (404) and passes after.Notes
This is the only Nitro-side change needed — everything downstream is already method-agnostic.
src/routing.tsandsrc/build/virtual/routing.tspass the method through as an opaque string, androu3uppercases it at match time. h3 v2 (rc.31, already pinned) hasQUERYin both itsHTTPMethodtype and itsHTTP_METHODSset, sodefineHandler/config handlers withmethod: "QUERY", theapp.query()shorthand, and method-scoped route rules like"QUERY /api/**"worked already.The Azure Functions
httpTriggermethod list insrc/presets/azure/utils.tswas left alone — it is a platform-supported list that already omitsconnect/trace.Unrelated pre-existing wrinkle spotted while working on this, not addressed here:
NitroEventHandler.methodis typed as h3'sHTTPMethod(uppercase only), while the scanner produces lowercase anddocs/3.configdocumentsmethod: "post". A config handler written asmethod: "query"(or"post") is a type error today even though it works at runtime.Verification
pnpm lint,pnpm typecheck,pnpm test:rollupandpnpm test:rolldownall pass (1073 tests each). The new test passes on every preset covered bytestNitro, including cloudflare/miniflare, aws-lambda, netlify, deno, bun and winterjs.🤖 Generated with AI assistant