Add request lifecycle hooks to support extensibility

オープン
#7,607 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
12/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
活発
技術スタック
express, javascript, node.js
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
JavaScript
スター
69.7k
フォーク
25.7k
平均マージ
2日 9時間
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

expressjs/express のほかの issue

expressjs/express の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。