Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@huseeiin
Copy link
Contributor

@huseeiin huseeiin commented Jan 12, 2026

  • changed void | Promise<void> to MaybePromise<void>
  • changed MaybePromise<void | Response> to unknown to allow non-Response types like string, json, etc. (don't worry, unknown allows promise)
  • changed MaybePromise<void | unknown> to unknown because its shorter and does the same

Summary by CodeRabbit

  • Refactor
    • Modified middleware hook signatures for request, response, and error handling to support more flexible return types.

✏️ Tip: You can customize this high-level summary in your review settings.

@huseeiin huseeiin requested a review from pi0 as a code owner January 12, 2026 14:51
@coderabbitai
Copy link

coderabbitai bot commented Jan 12, 2026

📝 Walkthrough

Walkthrough

Three middleware hook method signatures in the utilities module were updated to modify their return type constraints. The onRequest hook was standardized to use MaybePromise<void>, while both onResponse and onError hooks now accept unknown return types, broadening their flexibility.

Changes

Cohort / File(s) Change Summary
Middleware hook type signatures
src/utils/middleware.ts
onRequest hook: return type changed to MaybePromise<void>. onResponse hook: return type broadened from MaybePromise<void | Response> to unknown. onError hook: return type broadened from MaybePromise<void | unknown> to unknown.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop hooray! Our hooks now dance with grace,
Type constraints loosen in this place,
onRequest, onResponse, onError too,
Return types widen—so much more they can do!
Flexibility blooms in the midnight air,
A rabbit's refactor with thoughtful care! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The PR title 'types(onResponse): allow returning any value' accurately describes a main objective of the changeset—broadening the onResponse hook's return type to accept any value. However, it does not capture the full scope of changes, which also include refactoring onRequest and onError hook types.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks!

@pi0 pi0 changed the title fix(types): refactor middleware types types(onResponse): allow returning any value Jan 17, 2026
@pi0 pi0 merged commit 2b7718c into h3js:main Jan 17, 2026
4 checks passed
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