nodejs / nodejs/node

Add http.serve() API based on Fetch (Request -> Response)

Aperta
#63,096 8 commenti 38 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature request http
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

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.createServer directly.
  • Implement this in userland, or use existing 3rd party solutions.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando l’API http.createServer esistente di Node e la discussione nell’issue #42529. Il lavoro proposto consiste nel definire e aggiungere http.serve(handler) usando Request e Response, mantenendo disponibile createServer. Il lavoro è completo quando la forma e il comportamento dell’API sono concordati, implementati e verificati per gli handler sincroni e asincroni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, nodejs
Ambito
backend-api-design
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.