Skip to content

fix(build): stricter request body API removal with mode option - #86

Merged
yusukebe merged 1 commit into
nextfrom
fix/request-body-api-removal
Aug 17, 2026
Merged

fix(build): stricter request body API removal with mode option#86
yusukebe merged 1 commit into
nextfrom
fix/request-body-api-removal

Conversation

@yusukebe

Copy link
Copy Markdown
Member

Request body APIs could be removed even when code outside a handler reads the body, e.g. a service function called from app.all() or middleware (#64). The optimized app then crashes at runtime on a POST request.

Changes, based on @usualoma's proposal in the issue:

  • auto (default): remove the APIs only when every route method is strictly GET / HEAD / OPTIONS. A route or middleware registered with ALL keeps them
  • --request-body-api-removal <mode>: auto | force | disable (replaces --no-request-body-api-removal)
  • An invalid mode returns a JSON error (INVALID_OPTION)

With this, auto rarely fires for apps with middleware. That is intended: removal happens only when it is provably safe. If you know your app never reads request bodies, pass force.

Closes #64

The author should do the following, if applicable

  • Add tests
  • Run tests
  • pnpm run format:fix && pnpm run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

Co-authored-by: Taku Amano <taku@taaas.jp>
@yusukebe
yusukebe merged commit 1c13813 into next Aug 17, 2026
4 checks passed
@yusukebe
yusukebe deleted the fix/request-body-api-removal branch August 17, 2026 08:55
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