Support for promised middleware and readiness conditions
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
- 15/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- express, javascript, node.js
Direzione di ricerca
The issue names no files: it is a design proposal, so the first step is a maintainer decision on the API shape (async listen versus a separate listenAsync) before any code is written. To scope it, read how the app is created and started in lib/express.js and lib/application.js, and how middleware is stored and invoked in lib/router/layer.js. Done means an accepted design plus tests covering a promised middleware and waitFor on both App and Router.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
There are times when a service should wait for certain conditions to be in place before it starts accepting traffic. For instance: waiting for a database connection pool to be established.
Similarly, certain middleware may need to perform operations before it is ready to serve traffic. For example: a schema validator using openapi json schema files that needs to load the schemas before it is ready.
While modern esm can address this using top-level await, you either pay an ergonomics and readability penalty by having the middleware instantiated away from where it is used, or a performance penalty by awaiting and resolving each individually.
And this is completely unachievable using commonjs.
My proposal is as follows:
- App and Router gain a
waitForfunction that accepts Promises to be awaited on launch - Any place that accepts middleware also accepts a promise of middleware
- Either App.listen becomes async, or App gains a separate listenAsync function
- Optionally, App and Router gain a
readyfunction for code that might like to check readiness without booting the service
Example usage
import Genes from "../models/Genes.js";
import validate from "validateSchema";
import express from "express";
const router = new express.Router();
router.waitFor(Genes.ready());
router.route("/")
.get(
// validate returns a promise
validate("genes.yml#/listParams", "query"),
async (req, res) => {
res.json(await new Genes().get(listParameters(res.query))
}
);
router.route("/:geneId")
.put(
validate("genes.yml#/input", "body"),
async (req, res) => {
res.json(await new Genes().update(Number(req.params.geneId), req.body));
}
)
- Lingua principale
- JavaScript
- Stelle
- 69.7k
- Fork
- 25.7k
- Merge medio
- 2g 9h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di expressjs/express
-
Outdated res.send() syntax in lib/response.js documentation exampleForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertadocs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
expressjs/express#7588 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
4.x deps module:body-parser
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
expressjs/express#7564 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Update to mocha 12.xForse già presa @ganeshghutukade-04 l’ha presa 32 giorni fa. Apertadeps
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
expressjs/express#7547 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
req.subdomains splits an IPv6 host that contains dotsForse già presa @johnnyhuirilef l’ha presa 36 giorni fa. Aperta4.x 5.x bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
expressjs/express#7532 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Readme: project name 'express.js' is not capitalizedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di expressjs/express
Issue simili
-
docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
open-telemetry/opentelemetry.io#12846 ·
I maintainer di solito rispondono entro 1 giorno
-
Remove name=ChargeOneAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
osmlab/name-suggestion-index#13198 ·
I maintainer di solito rispondono entro 1 giorno
-
builtins good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
agent-os ai documentation enhancement good first issue help wanted model-experience
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
neomjs/neo-agent-skills#474 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue web
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno