Support for promised middleware and readiness conditions
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 15/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- express, javascript, node.js
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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));
}
)
- Ngôn ngữ chính
- JavaScript
- Star
- 69.7k
- Fork
- 25.7k
- Merge trung bình
- 2 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của expressjs/express
-
Outdated res.send() syntax in lib/response.js documentation exampleCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởdocs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
expressjs/express#7588 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
4.x deps module:body-parser
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
expressjs/express#7564 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update to mocha 12.xCó thể đã có người làm @ganeshghutukade-04 đã nhận 32 ngày trước. Đang mởdeps
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
expressjs/express#7547 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
req.subdomains splits an IPv6 host that contains dotsCó thể đã có người làm @johnnyhuirilef đã nhận 36 ngày trước. Đang mở4.x 5.x bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
expressjs/express#7532 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Readme: project name 'express.js' is not capitalizedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của expressjs/express
Issue tương tự
-
Go - Inconsistent Logs StabilityĐang mởdocs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
open-telemetry/opentelemetry.io#12846 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Remove name=ChargeOneĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
osmlab/name-suggestion-index#13198 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
builtins good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
agent-os ai documentation enhancement good first issue help wanted model-experience
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
neomjs/neo-agent-skills#474 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue web
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày