feat: add support for HTTP QUERY method (RFC 10008)#1938
Conversation
Add the HTTP QUERY method as defined in RFC 10008 to Elysia's router. This allows endpoints to handle QUERY requests for safe, idempotent operations that include a request body. Changes: - Add 'QUERY' to HTTPMethod type in types.ts - Add query() method to Elysia class in index.ts - Add tests for QUERY method routing and body handling Refs: elysiajs#1931
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
WalkthroughElysia now supports typed ChangesQUERY routing
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/index.tsOops! Something went wrong! :( ESLint: 9.39.4 Error: ESLint configuration in --config » plugin:sonarjs/recommended is invalid:
Referenced from: /.eslintrc.json ... [truncated 291 characters] ... /node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2952:16) src/types.tsOops! Something went wrong! :( ESLint: 9.39.4 Error: ESLint configuration in --config » plugin:sonarjs/recommended is invalid:
Referenced from: /.eslintrc.json ... [truncated 291 characters] ... /node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2952:16) test/core/query.test.tsOops! Something went wrong! :( ESLint: 9.39.4 Error: ESLint configuration in --config » plugin:sonarjs/recommended is invalid:
Referenced from: /.eslintrc.json ... [truncated 291 characters] ... /node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2952:16) 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 |
Summary
Add first-class support for the HTTP
QUERYmethod as defined in RFC 10008.This PR implements:
QUERYto theHTTPMethodtype unionquery()route helper to the Elysia class with full type inferenceMotivation
RFC 10008 introduces the QUERY method as a safe, idempotent alternative to POST for operations that need a request body. This is particularly useful for complex search queries that exceed URL length limits.
Refs: #1931
Testing
All tests pass:
Checklist
Summary by CodeRabbit
New Features
QUERYroutes.QUERYhandlers support request-body validation and parsed input.QUERYendpoints.Bug Fixes
QUERYrequests toQUERY-only routes correctly return a 404 response.