Add request lifecycle hooks to support extensibility

Aperta
#7,607 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
express, javascript, node.js
Ambito
backend

Direzione di ricerca

This is a design proposal, not a located change: it asks for enter/exit hooks around the app, router and route stages the request passes through, plus possibly middleware auto-wrapping. Start by reading how the router dispatches through its layers and where a request leaves one layer for another, then write up the hook points and their ordering/error semantics as a proposal for maintainers to agree on before any code. Done here means an accepted design (likely an RFC or discussion) rather than a patch, so it is not a starting point for a first contribution.

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

Descrizione

There are a number of features that I would like express to support. Things that I personally feel would improve ergonomics and ease of use. However, many of them involve a decision about a choice in direction and behavior that I suspect express would decline to make on behalf of users as a whole. For instance: I would like to support automatic output serialization based on content type and registered serializers.

I am willing to implement things like this for my own use, but I find myself stymied by the lack of hooks into the express routing process. While I can store a stack of scopes with registered serializers on the request, I have no way to guarantee the stack unwinds if the processing jumps to another route or router.

A robust system of hooks would not only support my own personal extensions, but enable an ecosystem of behavioral plugins.

The top lifecycle hooks that would help me personally are enter/exit hooks for app/router/route. Though there are probably other useful points that I am simply not thinking of at the moment.

I would also find the ability to auto-wrap middleware useful, but I don't know if that is too much to ask for at the moment.

Lingua principale
JavaScript
Stelle
69.7k
Fork
25.7k
Merge medio
2g 9h
PR unite (30g)
4

Preparare l'ambiente

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.

Altre issue di expressjs/express

Tutte le issue di expressjs/express

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.