Book Image

Web Development with MongoDB and Node.js

By : Jason Krol
Book Image

Web Development with MongoDB and Node.js

By: Jason Krol

Overview of this book

Table of Contents (19 chapters)
Web Development with MongoDB and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
12
Popular Node.js Web Frameworks
Index

Migrating to Express v4.0.0


The biggest change that comes with Express Version 4.0 is that Connect is no longer a dependency. Additionally, most of Express's (and subsequently Connect's) bundled middleware has been stripped out and moved into individual repositories. This is to help speed up the development and release cycles for both the newly separated middleware modules as well as Express itself. The only middleware that remains is express.static (for convenience). The good news here is that we're no longer required to use Express's (and by proxy Connect's) middleware by default!

The other big change is the way routes work. In previous versions the router was a part of the middleware and the routes were all defined as app. verb (). Now, you can either define a route object per route or just define routes by calling app.route('route').verb(callback). Let's go through the process of modifying our existing code so that it is ready to use Express Version 4.0.

Note

Please note that the remainder...