node.js - Koa 和 Express 4.0 有什么区别?

标签 node.js express frameworks koa

Koa 和 Express 4.0 都是相当新的版本,据我所知,Koa 是由 Express 团队制作的。

据我了解,Koa 需要 node 的特性,这些特性只在 node 的 0.11(不稳定分支)中可用,并且还使用了生成器。 Express 4.0 似乎只是 Express 框架的下一个版本。

有什么我完全遗漏的区别吗? Koa 和 Express 是否有可能(根据 Express 团队公开声明的内容)在未来某个时候合并?

谢谢!

最佳答案

在发布开放式问题之前,搜索引擎应该是您的首选。

From the Koa docs :

Koa vs Express

Philosophically, Koa aims to "fix and replace node", whereas Express "augments node". Koa uses co to rid apps of callback hell and simplify error handling. It exposes its own this.request and this.response objects instead of node's req and res objects.

Express, on the other hand, augments node's req and res objects with additional properties and methods and includes many other "framework" features, such as routing and templating, which Koa does not.

Thus, Koa can be viewed as an abstraction of node.js's http modules, where as Express is an application framework for node.js.

...

Does Koa replace Express?

It's more like Connect, but a lot of the Express goodies were moved to the middleware level in Koa to help form a stronger foundation. This makes middleware more enjoyable and less error-prone to write, for the entire stack, not just the end application code.

Typically many middleware would re-implement similar features, or even worse incorrectly implement them, when features like signed cookie secrets among others are typically application-specific, not middleware specific.

...

Why isn't Koa just Express 4.0?

Koa is a pretty large departure from what people know about Express, the design is fundamentally much different, so the migration from Express 3.0 to this Express 4.0 would effectively mean rewriting the entire application, so we thought it would be more appropriate to create a new library.

关于node.js - Koa 和 Express 4.0 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23140968/

相关文章:

javascript - 将 Mongoose 数据库中的内容上传到 React Component

javascript - 如何将 HTML 文本框表单输入放入 Express Route 参数

coldfusion - 使用 ColdFusion 框架

javascript - NodeJS Passport BasicStrategy 未经授权

node.js - 使用 express 服务 svg 文件

node.js - AWS ElastiCache 的 Redis 密码

javascript - Node : Can Passport be used to make Twitter API queries?

node.js - 使用 Passport 和 OAuth2 + 社交网络的 NodeJS REST 身份验证

PHP Slim 框架 - 多种 HTTP 方法

python - 如何避免大量嵌套的 if-elif-else 条件语句来评估许多情况下的快速响应?