Skip to content

feat: parse bodies for the HTTP QUERY method - #177

Open
WolfieLeader wants to merge 4 commits into
koajs:masterfrom
WolfieLeader:feat/parse-query-method
Open

feat: parse bodies for the HTTP QUERY method#177
WolfieLeader wants to merge 4 commits into
koajs:masterfrom
WolfieLeader:feat/parse-query-method

Conversation

@WolfieLeader

@WolfieLeader WolfieLeader commented Aug 13, 2026

Copy link
Copy Markdown

New QUERY method

Added the new (June 2026) QUERY method

Checklist

  • I have ensured my pull request is not behind the main or master branch of the original repository.
  • I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
  • I have written a commit message that passes commitlint linting.
  • I have ensured that my code changes pass linting tests.
  • I have ensured that my code changes pass unit tests.
  • I have described my pull request and the reasons for code changes along with context if necessary.

Summary by Sourcery

Support parsing request bodies for the HTTP QUERY method alongside existing methods.

New Features:

  • Add QUERY to the default list of HTTP methods whose bodies are parsed by the body parser.

Documentation:

  • Update README to document QUERY as part of the default parsedMethods configuration.

Tests:

  • Add a middleware test verifying JSON body and raw body parsing on QUERY requests.

Summary by CodeRabbit

  • New Features

    • JSON request bodies are now parsed by default for QUERY requests, alongside POST, PUT, and PATCH.
    • QUERY parsing can be excluded by customizing the configured parsed methods.
  • Documentation

    • Updated documentation to include QUERY in the default parsed methods and clarified raw-checking behavior.
  • Tests

    • Added coverage for default and customized QUERY request parsing.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

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: Pro Plus

Run ID: 17477200-7db1-4644-acfe-946b37be8326

📥 Commits

Reviewing files that changed from the base of the PR and between 4d391a3 and 8d5cac8.

📒 Files selected for processing (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

📝 Walkthrough

Walkthrough

The default parsedMethods list now includes QUERY alongside POST, PUT, and PATCH. The implementation and public documentation reflect this default. Middleware tests verify JSON parsing for QUERY requests and confirm that parsing remains disabled when QUERY is excluded from the configured methods.

Mergeability Score: ⚪ Minimal · up to 8d5ca

The PR adds QUERY to the methods whose request bodies are parsed and updates the related documentation; no actionable merge-blocking risk remains based on the supplied evidence.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: parsing request bodies for the HTTP QUERY method.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@sourcery-ai

sourcery-ai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR extends the body parser to treat the new HTTP QUERY method as a parsed method by default, updating implementation defaults, type documentation, and README, and adds a test to assert JSON body parsing for QUERY requests.

Sequence diagram for JSON body parsing on HTTP QUERY requests

sequenceDiagram
  actor Client
  participant NodeServer
  participant bodyParserWrapper
  participant AppMiddleware

  Client->>NodeServer: HTTP QUERY with JSON body
  NodeServer->>bodyParserWrapper: bodyParserWrapper(opts)
  bodyParserWrapper->>bodyParserWrapper: check parsedMethods includes QUERY
  bodyParserWrapper->>NodeServer: set request.body
  NodeServer->>AppMiddleware: app.use(ctx)
  AppMiddleware->>AppMiddleware: read ctx.request.body
Loading

File-Level Changes

Change Details Files
Add QUERY to the set of HTTP methods whose request bodies are parsed by default.
  • Update bodyParserWrapper default parsedMethods array to include QUERY
  • Update BodyParserOptions parsedMethods JSDoc default to include QUERY
src/body-parser.ts
src/body-parser.types.ts
Align documentation and tests with the new QUERY body parsing behavior.
  • Update README to document QUERY as a default parsed method
  • Add middleware test that sends a JSON body with a QUERY request and asserts parsed body and rawBody
README.md
test/middleware.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The default parsed methods list is now defined in multiple places (implementation, types JSDoc, README); consider centralizing this into a single constant to avoid future inconsistencies.
  • Given QUERY is now a default parsed method, it may be useful to add a test that explicitly overrides parsedMethods to exclude QUERY to ensure the opt-out behavior continues to work as expected.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The default parsed methods list is now defined in multiple places (implementation, types JSDoc, README); consider centralizing this into a single constant to avoid future inconsistencies.
- Given QUERY is now a default parsed method, it may be useful to add a test that explicitly overrides `parsedMethods` to exclude QUERY to ensure the opt-out behavior continues to work as expected.

## Individual Comments

### Comment 1
<location path="README.md" line_range="93" />
<code_context>

 - **enableRawChecking**: support the already parsed body on the raw request by override and prioritize the parsed value over the sended payload. (default is `false`)

-- **parsedMethods**: declares the HTTP methods where bodies will be parsed, default `['POST', 'PUT', 'PATCH']`.
</code_context>
<issue_to_address>
**issue (typo):** Use correct past participle "sent" instead of "sended".

Please change "sended payload" to "sent payload" for grammatical correctness and readability.

```suggestion
- **enableRawChecking**: support the already parsed body on the raw request by override and prioritize the parsed value over the sent payload. (default is `false`)
```
</issue_to_address>

### Comment 2
<location path="README.md" line_range="97" />
<code_context>
-- **parsedMethods**: declares the HTTP methods where bodies will be parsed, default `['POST', 'PUT', 'PATCH']`.
+- **parsedMethods**: declares the HTTP methods where bodies will be parsed, default `['POST', 'PUT', 'PATCH', 'QUERY']`.

 - **disableBodyParser**: you can dynamic disable body parser by set `ctx.disableBodyParser = true`.

</code_context>
<issue_to_address>
**suggestion (typo):** Improve grammar in the description of disabling the body parser.

Consider rephrasing to: "you can dynamically disable the body parser by setting `ctx.disableBodyParser = true`."
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread README.md Outdated
Comment thread README.md Outdated
@WolfieLeader

Copy link
Copy Markdown
Author

Fixed those

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