Expressjs is the NODEJS Web development Framework, the latest version is 4.0 compared to the 3.x version, the Expressjs 4.X version made some of the following changes:
1. To remove middleware bindings, the use of all middleware must be downloaded separately and then loaded, so the benefits of the design is that users can download the middleware and updates needed for the project on demand as needed.
var app = Express (); // 3.X version, use of middleware App.use (Express.bodyparser ()); App.use (Express.cookieparser ()); // version 4.0, middleware needs to be loaded separately var cookieparser = require (' Cookie-parser '); var bodyparser = require (' Body-parser '); // Use App.use (Cookieparser ()); App.use (Bodyparser ()):
2.app.configure () is not in a valid, environment-based parameter configuration as long as it is configured through a simple IF-ELSE statement block, such as a development environment:
// Expressjs 3.xapp.configure (' development ' function({ // to do })); // EXPRESSJS 4.0 var env = Process.env.NODE_ENV | | ' Development ' ; if (' development ' = = env) {//to do};
3. Changes in routing.
The processing of Expressjs 3.x routes is generally:
App.get ('/' function(res, res, next) { // todo}); App.post ( function(res , res, next) {});
Expressjs4.0 adds a number of alternative ways to routing, such as through the app. Router instances
var app = Express (); var router = Express. Router (); Router.get (function(req, res) {..}); Router.post ('/users ',function(req,res) {...}); // call route, you can specify the root directory app.use ('/' , router);
More reference http://scotch.io/bar-talk/expressjs-4-0-new-features-and-upgrading-from-3-0