3.x API 参考
Express 3.x IS END-OF-LIFE AND NO LONGER MAINTAINED
自上次更新(2015年8月1日)以来,3.x 中已知和未知的安全性及性能问题尚未得到解决。强烈建议使用 Express 的最新版本。
🌐 Known and unknown security and performance issues in 3.x have not been addressed since the last update (1 August, 2015). It is highly recommended to use the latest version of Express.
如果你无法升级到3.x以上,请考虑商业支持选项。
🌐 If you are unable to upgrade past 3.x, please consider Commercial Support Options.
Note
Express 3.x 需要 Node.js 0.8.0 或更高版本。
🌐 Express 3.x requires Node.js 0.8.0 or higher.
3.x API
本部分概述了在 Express 3.x 中用于构建网页应用和 HTTP 服务的模块和 API。
🌐 This section provides an overview of the modules and APIs available in Express 3.x for building web applications and HTTP services.
express()
express 模块导出的 express() 函数会创建并返回一个新的应用实例,该实例用作定义路由、配置中间件和处理 HTTP 请求的基础。
🌐 The express() function, exported by the express module, creates and returns a new application instance that serves as the foundation for defining routes, configuring middleware, and handling HTTP requests.
var express = require('express');var app = express();
app.get('/', function (req, res) { res.send('hello world');});
app.listen(3000);在创建应用实例后,你可以定义路由、配置中间件,并开始处理 HTTP 请求
🌐 After creating an application instance, you can define routes, configure middleware, and start handling HTTP requests
应用对象
Learn about the properties and methods of the Express 3.x application object.
请求对象
Learn about the properties and methods of the Express 3.x request object.
响应对象
Learn about the properties and methods of the Express 3.x response object.
中间件
Learn about middleware in Express 3.x, including built-in and third-party options.