Skip to content

feat: fetchNodeHandler and toWebHandler #125

Merged
pi0 merged 11 commits into
mainfrom
feat/fetch-node
Oct 17, 2025
Merged

feat: fetchNodeHandler and toWebHandler #125
pi0 merged 11 commits into
mainfrom
feat/fetch-node

Conversation

@pi0

@pi0 pi0 commented Oct 16, 2025

Copy link
Copy Markdown
Member

This PR adds a built-in utility to convert Node handler format into Web.

This adds compatibility for fetching node handlers like Express.

When the handler is executed in a srvx node server, we detect it and use the fast path of directly passing the original node req, res through.

Otherwise, we create a virtual node Socket that streams input for the web Request body and intercepts raw writes to extract HTTP headers + streamed body.


This approach is fudumentally different than fetch-to-node and http-compute-js, and node-mock-http as those try to emulate all interfaces which in turns makes trouble for using with express (as express uses original node OutgoingMessage prototype. See unjs/node-mock-http#5. This approach ensured Node.js behavior is untouched.


Followup for Deno and Bun runtime support: #132

@codecov

codecov Bot commented Oct 17, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.50847% with 46 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/adapters/_node/web/socket.ts 74.24% 34 Missing ⚠️
src/adapters/_node/web/fetch.ts 68.75% 10 Missing ⚠️
src/adapters/_node/web/response.ts 95.23% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@pi0 pi0 changed the title feat: fetchNodeHandler feat: fetchNodeHandler and nodeToFetchHandler Oct 17, 2025
@pi0 pi0 merged commit 88f33af into main Oct 17, 2025
4 checks passed
@pi0 pi0 deleted the feat/fetch-node branch October 17, 2025 10:05
@pi0 pi0 changed the title feat: fetchNodeHandler and nodeToFetchHandler feat: fetchNodeHandler and toWebHandler Oct 29, 2025
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