-
-
Notifications
You must be signed in to change notification settings - Fork 17k
Migrating from 3.x to 4.x
Express 3.x to 4.0 migration guide. You may also be interested in New features in 4.x.
See Express 4.x docs for more examples and complete API documentation.
Express 4 no longer has connect as a dependency. This means that ALL of the bundled middleware (except static
) is no longer available on the express
module. Each of these middlewares is available as modules referenced below. This change was made to allow for these middleware to receive fixes, updates, and releases without impacting express release cycles and vice versa.
- bodyParser body-parser
- cookieParser cookie-parser
- favicon static-favicon
- session express-session
others documented here https://github.com/senchalabs/connect#middleware
This method is no longer available. If you wish to configure different routes based on environment, use an if statement or alternative module.
app.configure('development', function() {
// configure stuff here
});
// becomes
var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
// configure stuff here
}
The middleware stack has been overhauled to avoid confusion with .use
vs .get
(or other HTTP verbs) and as a result, the need to every manually do app.use(app.router)
has been removed. See the Routers section below on the new middleware and routing apis.
Long deprecated. Just use express()
to create a new app.
All connect middleware lives in separate modules with the exception of express.static
which is provided for convenience. Everything else benefits from being a separate module with its own versioning.
Use req.accepts()
instead.
req.accepts()
req.acceptsEncodings()
req.acceptsCharsets()
req.acceptsLanguages()
All use accepts internally.
Please refer to accepts
for any issues or documentation requests.
No longer does relative URL resolution. Browsers will handle relative urls themselves.
When mounting an express app in another express app
-
json spaces
no longer enabled by default in development
Is now an object instead of an array. This will not break your app if you used the req.params[##]
style for regexp routes where parameter names are not known.
Is no longer a function. It is a plain js object. Treat it as such.
Changed to headersSent
to match the node.js ServerResponse object. Your app likely didn't use this and thus it won't be an issue.
Uses type-is internally now.
Please refer to type-is
for any issues or documentation requests.
Returns a new Route
instance. A Route is invoked when a request matching the route path
is received. Routes can have their own middleware stacks and have methods for the http VERBS to process requests.
See the Routes and Routing docs to better understand how to create routes in express.
The Router has been overhauled to be a full fledge middleware router. The Router is a good way to separate your routes into files/modules without sacrificing features like parameter matching and middleware. See the Routes and Routing docs.