返回介绍

Express 中间件

发布于 2020-12-20 08:19:48 字数 6339 浏览 1110 评论 0 收藏 0

Express middleware

The Express middleware modules listed here are maintained by the Expressjs team.

Middleware moduleDescriptionReplaces built-in function (Express 3)
body-parserParse HTTP request body. See also: body, co-body, and raw-body.express.bodyParser
compressionCompress HTTP responses.express.compress
connect-ridGenerate unique request ID.NA
cookie-parserParse cookie header and populate req.cookies. See also cookies and keygrip.express.cookieParser
cookie-sessionEstablish cookie-based sessions.express.cookieSession
corsEnable cross-origin resource sharing (CORS) with various options.NA
csurfProtect from CSRF exploits.express.csrf
errorhandlerDevelopment error-handling/debugging.express.errorHandler
method-overrideOverride HTTP methods using header.express.methodOverride
morganHTTP request logger.express.logger
multerHandle multi-part form data.express.bodyParser
response-timeRecord HTTP response time.express.responseTime
serve-faviconServe a favicon.express.favicon
serve-indexServe directory listing for a given path.express.directory
serve-staticServe static files.express.static
sessionEstablish server-based sessions (development only).express.session
timeoutSet a timeout period for HTTP request processing.express.timeout
vhostCreate virtual domains.express.vhost

Additional middleware modules

These are some additional popular middleware modules.

Warning: This information refers to third-party sites, products, or modules that are not maintained by the Expressjs team. Listing here does not constitute an endorsement or recommendation from the Expressjs project team.

Middleware moduleDescription
cls-rtracerMiddleware for CLS-based request id generation. An out-of-the-box solution for adding request ids into your logs.
connect-image-optimusOptimize image serving. Switches images to .webp or .jxr, if possible.
express-debugDevelopment tool that adds information about template variables (locals), current session, and so on.
express-partial-responseFilters out parts of JSON responses based on the fields query-string; by using Google API’s Partial Response.
express-simple-cdnUse a CDN for static assets, with multiple host support.
express-slashHandles routes with and without trailing slashes.
express-stormpathUser storage, authentication, authorization, SSO, and data security.
express-uncapitalizeRedirects HTTP requests containing uppercase to a canonical lowercase form.
helmetHelps secure your apps by setting various HTTP headers.
join-ioJoins files on the fly to reduce the requests count.
passportAuthentication using “strategies” such as OAuth, OpenID and many others. See http://passportjs.org/ for more information.
static-expiryFingerprint URLs or caching headers for static assets.
view-helpersCommon helper methods for views.
sriracha-adminDynamically generate an admin site for Mongoose.

For more middleware modules, see http-framework.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文