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.
目录
相关文章
|
23天前
|
JavaScript 前端开发 中间件
探索后端技术:Node.js与Express框架的完美融合
【10月更文挑战第7天】 在当今数字化时代,Web应用已成为日常生活不可或缺的一部分。本文将深入探讨后端技术的两大重要角色——Node.js和Express框架,分析它们如何通过其独特的特性和优势,为现代Web开发提供强大支持。我们将从Node.js的非阻塞I/O和事件驱动机制,到Express框架的简洁路由和中间件特性,全面解析它们的工作原理及应用场景。此外,本文还将分享一些实际开发中的小技巧,帮助你更有效地利用这些技术构建高效、可扩展的Web应用。无论你是刚入门的新手,还是经验丰富的开发者,相信这篇文章都能为你带来新的启发和思考。
|
2天前
|
JavaScript 中间件 关系型数据库
构建高效的后端服务:Node.js 与 Express 的实践指南
在后端开发领域,Node.js 与 Express 的组合因其轻量级和高效性而广受欢迎。本文将深入探讨如何利用这一组合构建高性能的后端服务。我们将从 Node.js 的事件驱动和非阻塞 I/O 模型出发,解释其如何优化网络请求处理。接着,通过 Express 框架的简洁 API,展示如何快速搭建 RESTful API。文章还将涉及中间件的使用,以及如何结合 MySQL 数据库进行数据操作。最后,我们将讨论性能优化技巧,包括异步编程模式和缓存策略,以确保服务的稳定性和扩展性。
|
9天前
|
Web App开发 JavaScript 中间件
构建高效后端服务:Node.js与Express框架的完美结合
【10月更文挑战第21天】本文将引导你走进Node.js和Express框架的世界,探索它们如何共同打造一个高效、可扩展的后端服务。通过深入浅出的解释和实际代码示例,我们将一起理解这一组合的魅力所在,并学习如何利用它们来构建现代Web应用。
31 1
|
23天前
|
JSON JavaScript 前端开发
Node.js Express 框架
10月更文挑战第7天
23 2
|
27天前
|
JSON JavaScript 前端开发
使用 Node.js 和 Express 构建 RESTful API
【10月更文挑战第3天】 使用 Node.js 和 Express 构建 RESTful API
|
2月前
|
JavaScript
NodeJs的安装
文章介绍了Node.js的安装步骤和如何创建第一个Node.js应用。包括从官网下载安装包、安装过程、验证安装是否成功,以及使用Node.js监听端口构建简单服务器的示例代码。
NodeJs的安装
|
28天前
|
JavaScript 开发工具 git
已安装nodejs但是安装hexo报错
已安装nodejs但是安装hexo报错
21 2
|
2月前
|
存储 JavaScript 前端开发
Node 版本控制工具 NVM 的安装和使用(Windows)
本文介绍了NVM(Node Version Manager)的Windows版本——NVM for Windows的安装和使用方法,包括如何安装Node.js的特定版本、列出已安装版本、切换使用不同版本的Node.js,以及其他常用命令,以实现在Windows系统上对Node.js版本的便捷管理。
Node 版本控制工具 NVM 的安装和使用(Windows)
|
22天前
|
Web App开发 JavaScript 前端开发
JavaWeb 22.Node.js_简介和安装
JavaWeb 22.Node.js_简介和安装
|
2月前
|
SQL JavaScript 数据库
sqlite在Windows环境下安装、使用、node.js连接
sqlite在Windows环境下安装、使用、node.js连接