Skip to content

Migrating from 2.x to 3.x

visionmedia edited this page Nov 10, 2011 · 48 revisions

Removed

  • res.render() "status" option (use res.statusCode=)
  • res.render() "charset" option (use res.charset=)
  • app.dynamicHelpers() (use app.locals.use(callback))
  • app.helpers() (use app.locals)
  • app.VERB(path) for route lookup
  • the concept of a "layout" (template engine specific now)
  • partial() (template engine specific)
  • res.partial()
  • "view options" setting, use app.locals
  • "hints" setting
  • req.isXMLHttpRequest (use req.xhr)
  • app.error() (use middleware with (err, req, res, next))

Changed

  • res.send(body[, code]) is now res.send([code,] body)
  • res.redirect(url[, code]) is now res.redirect([code,] url)
  • res.json(obj[, code]) is now res.json([code,] obj)
  • renamed app.register() to app.engine()

Added

  • app "root" setting
  • app.get(setting) => value
  • req.secure to check if the request was made via HTTPS
  • req.path to grab the url pathname
  • new tests using mocha
  • res.set(field, value) to set a header field value
  • res.set(obj) to set several values
  • res.locals.NAME = val
  • res.locals(obj) to set several locals
  • app.locals.NAME = val
  • app.locals(obj) to set several app-level locals
  • app.render()
  • res.type() alias of res.contentType()
  • res.clearCookie() "path" defaults to the "root" setting
  • res.cookie() "path" defaults to the "root" setting
  • res.headerSent
  • res.charset=
  • req.stale
  • req.fresh
  • JSON cookie support
  • signed cookie support

Fixed

  • several subtle res.sendfile() bugs

Clone this wiki locally