-
Notifications
You must be signed in to change notification settings - Fork 34
chore(toFetchHandler): allow HTTP/1 handler type #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe PR adds TypeScript support for Node.js HTTP/1.x handlers by introducing a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/adapters/_node/adapter.ts (1)
45-48: Consider adding JSDoc for the new type.The
NodeHttp1Handlertype definition correctly represents Express-style handlers. Consider adding a brief JSDoc comment to document its purpose for future maintainers.📝 Optional: Add documentation
+/** + * Node.js HTTP/1.x handler type for compatibility with libraries like Express. + */ type NodeHttp1Handler = ( req: NodeHttp.IncomingMessage, res: NodeHttp.ServerResponse, ) => void | Promise<void>;
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/adapters/_node/adapter.ts
🔇 Additional comments (2)
src/adapters/_node/adapter.ts (2)
1-1: LGTM!The type-only import is appropriate for defining the
NodeHttp1Handlertype and adds no runtime overhead.
54-69: The type union addition is safe. WhileNodeHttp1Handleris cast toNodeHttpHandleron lines 62 and 66, both handler types are compatible at runtime becauseWebIncomingMessageextendsNodeHttp.IncomingMessageandWebServerResponseextendsNodeHttp.ServerResponse, which satisfy both signatures. The actual objects passed to the handler are always HTTP/1 types, making the cast valid.
resolves #149
This is a type-only compatibility improvement for the
toFetchHandlerutility, making it compatible with libraries that only support HTTP/1, e.g., express.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.