expressjs
Express 5.0 is currently in the alpha release stage and it will not be quite different from Express 4. While the underlying API remains the same as that of Express 4, you may need to watch for some deprecated methods that may break your application when you upgrade.
Express 5.0当前处于Alpha发行阶段,与Express 4并没有太大区别。 虽然基础API与Express 4相同,但是您可能需要注意一些不推荐使用的方法,这些方法在升级时可能会破坏您的应用程序 。
It should, however, be a smooth transition between Express v4 and Express v5 as we will see in the following examples.
但是,这应该是Express v4和Express v5之间的平滑过渡,如以下示例所示。
We've built APIs on Express 4, so we're very excited to see that 5 is coming shortly
我们已经在Express 4上构建了API ,因此我们很高兴看到5即将推出
设置Express 5项目 ( Setting Up An Express 5 Project )
To get started, set up a new node project with npm init
and install the latest Express 5 alpha release from npmjs. You can always refer to the release logs from the Express repository's history.md file.
首先,使用npm init
设置一个新的节点项目,并从npmjs安装最新的Express 5 alpha版本。 您始终可以从Express资源库的history.md文件中引用发布日志。
$npm install express@5.0.0-alpha.3 --save
We are now ready to see some of the changes. Most of the methods and properties that we will look at here were previously deprecated and have been completely removed in Express 5.
现在,我们准备看到一些更改。 我们将在此处介绍的大多数方法和属性以前均已弃用,并已在Express 5中完全删除。
不推荐使用的方法和属性 ( Deprecated Methods And Properties )
app.del()
app.del()
app.del()
has been removed as a HTTP DELETE registration method in favor of app.delete()
.
app.del()
已被移除为HTTP DELETE注册方法,而支持app.delete()
。
app.del('/resource', (req, res) => res.send('deleted'));
//4: express deprecated app.del: Use app.delete instead
//5: TypeError: app.del is not a function
app.param(fn)
app.param(fn)
The app.param(fn) signature was used for modifying the behavior of the app.param(name, fn) function. It has been deprecated since v4.11.0, and Express 5 no longer supports it at all.
app.param(fn)签名用于修改app.param(name,fn)函数的行为。 从v4.11.0开始不推荐使用它,Express 5不再支持它。