Node.js开发者有福了!Express 3.0发布

简介: Express 3.0是一个维护版本,针对2.x版修复了很多问题,并加入了很多新功能。 在使用Express框架时,要记住,Express框架是帮助开发者快速实现HTTP通信相关的功能,而不是成为像Rails那样功能强大、全面的框架。

Express 3.0是一个维护版本,针对2.x版修复了很多问题,并加入了很多新功能。


在使用Express框架时,要记住,Express框架是帮助开发者快速实现HTTP通信相关的功能,而不是成为像Rails那样功能强大、全面的框架。

Connect 2.x

Changes introduced by Connect 2.x:

added err.status support to Connect’s default end-point
added session() “proxy” setting to trust “X-Forwarded-Proto”
added cookieSession() middleware
added compress() middleware for gzipped responses
added multipart() middleware
added json() middleware
added urlencoded() middleware
added limit option to the three above middleware
added defer option to multipart() to listen on formidable’s events
added debug() instrumentation to aid in debugging
changed basicAuth()’s req.remoteUser to req.user
changed session() to only set-cookie on modification (hashed session json)
changed bodyParser() to be an aggregate of json(), multipart() and urlencoded()
moved many cookie-related utils into npm
moved static()’s logic into a separate npm module named “send”
increase perf ~%20 by memoizing url parsing
removed router() middleware
fixed default encoding for logger(), now “utf8” instead of “ascii”
fixed mount-path case-sensitivity

Connect docs are available at http://www.senchalabs.org/connect/, and will eventually be mirrored on expressjs.com as well for convenience, along with usage guides.

作者:chszs,转载需注明。作者博客主页:http://blog.csdn.net/chszs


Express 3.x


Changes introduced by Express 3.x:

added several new examples in ./examples
added unit testing for the examples (most of them at least)
added res.jsonp() to explicitly opt-in to JSONP support
added ETags and conditional-GET handling to res.send() responses
added “jsonp callback name” setting
added support for status code as first or second arg to res.send() and res.redirect()
added req.range(size) to parse Range header fields
added req.auth for basic auth
added res.links(obj) to set response the Link header field for pagination
added res.format(obj) for content-negotiation
added req.fresh for conditional-GETs
added req.stale for conditional-GETs
added mount-point relative redirection support to res.redirect()
added req.ip for the remote address (supporting reverse proxies)
added req.ips for remote address(es) (supporting reverse proxies)
added [] support in jsonp callback
added app.get(name) to compliment app.set(name, val)
added app.engine() to register template engines (replaces app.register())
added req.subdomains to return an array of subdomains
added req.protocol to return the request protocol string (“http” or “https”)
added req.secure to assert that req.protocol is “https”
added req.path to return the parsed url’s pathname
added req.host to return hostname (Host void of port)
added debug() instrumentation to aid debugging
added req.accepts()
added req.acceptsLanguage()
added req.acceptsCharset()
added req.accepted
added req.acceptedLanguages
added req.acceptedCharsets
added “json replacer” setting to manipulate json responses (remove private keys etc)
added “json spaces” setting to compress or expand json as you like (defaults to 2 in dev)
added express.application prototype
added express.request prototype
added express.response prototype
added app.render() for app-level templates
added res.type() to replace old res.contentType()
added { signed: true } option to res.cookie()
added async signature to res.render(), engines in consolidate.js work OOTB
removed partial()
removed express-level layout support (engines provide similar)
renamed “case sensitive routes” to “case sensitive routing”
removed res.signedCookie()
removed “root” setting
removed res.redirect('home') support
removed req.notify()
removed app.register()
removed app.redirect()
removed app.is()
removed app.helpers()
removed app.dynamicHelpers()

Head over to the New Features in 3.x wiki page for a more comprehensive list of additions, or to 3.x migration to help you upgrade if you wish to do so.
目录
相关文章
|
1月前
|
缓存 负载均衡 JavaScript
构建高效后端服务:Node.js与Express框架实践
在数字化时代的浪潮中,后端服务的重要性不言而喻。本文将通过深入浅出的方式介绍如何利用Node.js及其强大的Express框架来搭建一个高效的后端服务。我们将从零开始,逐步深入,不仅涉及基础的代码编写,更会探讨如何优化性能和处理高并发场景。无论你是后端新手还是希望提高现有技能的开发者,这篇文章都将为你提供宝贵的知识和启示。
|
1月前
|
JavaScript
使用node.js搭建一个express后端服务器
Express 是 Node.js 的一个库,用于搭建后端服务器。本文将指导你从零开始构建一个简易的 Express 服务器,包括项目初始化、代码编写、服务启动与项目结构优化。通过创建 handler 和 router 文件夹分离路由和处理逻辑,使项目更清晰易维护。最后,通过 Postman 测试确保服务正常运行。
49 1
|
29天前
|
Web App开发 JSON JavaScript
Node.js 中的中间件机制与 Express 应用
Node.js 中的中间件机制与 Express 应用
|
1月前
|
Web App开发 JavaScript 前端开发
探索后端开发:Node.js与Express的完美结合
【10月更文挑战第33天】本文将带领读者深入了解Node.js和Express的强强联手,通过实际案例揭示它们如何简化后端开发流程,提升应用性能。我们将一起探索这两个技术的核心概念、优势以及它们如何共同作用于现代Web开发中。准备好,让我们一起开启这场技术之旅!
47 0
|
1月前
|
Web App开发 JavaScript 前端开发
构建高效后端服务:Node.js与Express框架的实践
【10月更文挑战第33天】在数字化时代的浪潮中,后端服务的效率和可靠性成为企业竞争的关键。本文将深入探讨如何利用Node.js和Express框架构建高效且易于维护的后端服务。通过实践案例和代码示例,我们将揭示这一组合如何简化开发流程、优化性能,并提升用户体验。无论你是初学者还是有经验的开发者,这篇文章都将为你提供宝贵的见解和实用技巧。
|
Web App开发 JavaScript 前端开发
[译] JavaScript 开发者年度调查报告
本文讲的是[译] JavaScript 开发者年度调查报告,截至目前有超过了 5000 人参与了(该次调查),准确的说是 5350 人。我迫不及待的想要和大家分享一下这次调查的细节。在分享之前我想要感谢参与调查的每一个人。这是 JavaScript 社区一个伟大的时刻,我对未来的事情感到无比激动。
1297 0
|
Web App开发 JavaScript 前端开发
|
JavaScript 前端开发 测试技术
|
Web App开发 JavaScript 前端开发
|
1月前
|
JavaScript 前端开发
JavaScript中的原型 保姆级文章一文搞懂
本文详细解析了JavaScript中的原型概念,从构造函数、原型对象、`__proto__`属性、`constructor`属性到原型链,层层递进地解释了JavaScript如何通过原型实现继承机制。适合初学者深入理解JS面向对象编程的核心原理。
26 1
JavaScript中的原型 保姆级文章一文搞懂