Koa vs Express
来源:互联网 发布:iwatch软件排行 编辑:程序博客网 时间:2024/06/14 20:56
点击这里查看原文
Koa vs Express
在价值观上, Koa 宣称”fix and replace node”,而Express则为”augments node”。Koa 通过co库摆脱回调的坑并且简化异常处理。
它通过暴露出自己的this.request
和 this.response
对象代替node自身的req
和 res
对象。相反的,Express为node自身的req
和 res
对象添加附加的属性和方法,并且包含了许多的框架特性。比如,路由和模板。
因此,Koa可以看作是node.js的http
模块的抽象,Express 是node.js的一个应用框架。
因此,如果你喜欢node.js和原生node.js风格的代码,你也许会坚持用Connect/Express 或者更加轻量级的框架。如果期望玩转generators,那就用Koa吧。
基于这个不同,传统的node.js中间件(形如 (req, res, next)
的函数)和Koa不兼容。你的应用可能会整个重写。
Koa 会代替 Express?
它更像Connect,但是许多的Express 黑科技都转变成了帮助Koa形成强大接触的中间件。这使得编写全栈中间件更加随意,而不仅仅是后端代码。
特别是很多中间件会重复实现相同的特性,更糟糕的是错误的实现它们。例如类似signed cookie secrets的特性是典型的属于应用而不是中间件。
Koa 会代替Connect?
generators 是的我们在代码中用更少的回调,Connect 同样有能力,有些人可能还是喜欢它,这取决于你喜欢什么。
为什么不用Koa 而是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.
How is Koa different than Connect/Express?
Generator-based control flow
Thanks to co.
No callback hell.
Better error handling through try/catch.
No need for domains.
Koa is barebones
Unlike both Connect and Express, Koa does not include any middleware.
Unlike Express, routing is not provided.
Unlike Express, many convenience utilities are not provided. For example, sending files.
Koa is more modular.
Koa relies less on middleware
For example, instead of a “body parsing” middleware, you would instead use a body parsing function.
Koa abstracts node’s request/response
Less hackery.
Better user experience.
Proper stream handling.
- Koa vs Express
- [转] Node.js 框架比较: Express vs. Koa vs. Hapi
- Node.js 框架比较: Express vs. Koa vs. Hapi
- express与koa对比
- Koa、Express Web单元测试
- [译]Node.js 框架比较: Express vs. Koa vs. Hapi
- Express和koa各有啥优缺点?
- nodejs原生,express,koa跨域问题解决
- node,express,koa,koa2跨域问题
- express和koa中的超时处理
- Koa
- Nodejs-Express, Koa, Hapi三个框架应如何选择
- Node.js框架之express与koa对比分析
- VS 2008 Express
- vs 2010 express 序列号
- vs 2010 iis express
- vs 11 express 显示datapicker
- vs自带的sql express
- Map方法获取默认值
- 单点登录限制下暴露的新漏洞及规避方法
- intellij idea入门,基础功能介绍
- 自定义ViewPager XML文件无法识别问题
- QuotedString 和 UnquotedString 区别
- Koa vs Express
- android 接口回调
- iOS 静态库开发(.a)( framework)
- 调取相机--------头像拍照
- android 热修复
- c++之window filesearch和LoadLibraryA的实现
- IOS制作星星加分效果
- 坚持#第12天~跑酷成品了
- HDU5831 Rikka with Parenthesis II