Add http.serve() API based on Fetch (Request -> Response)
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.3k
- 平均合并
- 4 天 2 小时
- 30 天内合并 PR
- 283
描述
What is the problem this feature will solve?
Node provides fetch, Request/Response, and Web Streams, but no high level server API using this model.
Other runtimes such as Deno and Bun expose a serve API based on the Fetch contract. In Node, similar patterns are commonly implemented in userland (e.g., frameworks like Hono), which indicates demand for this abstraction.
This was discussed in #42529 and received support, however that issue is focused on request.toWeb(), so opening a separate issue focused on this API.
What is the feature you are proposing to solve the problem?
Add a high-level http.serve(handler) API.
An example shape could be:
http.serve((req) => new Response("ok"))
handler: (Request) => Response | Promise<Response>
This would coexist with the existing http.createServer, and be a high level alternative using WHATWG APIs instead.
What alternatives have you considered?
- Continue using
http.createServerdirectly. - Implement this in userland, or use existing 3rd party solutions.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先查看 Node 现有的 http.createServer API 以及 issue #42529 中的讨论。拟议的工作是使用 Request 和 Response 定义并添加 http.serve(handler),同时保留 createServer 可用。完成的标准是 API 的形式和行为已达成一致、完成实现,并覆盖同步和异步 handler。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, nodejs
- 领域
- backend-api-design
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100