Man: Express 4 is starting to reach the release candidate phases. Let's migrate to Express 4 now so that we can focus on that moving forward.
I'll "npm express install firstname.lastname@example.orgRC3" to grab the third release candidate, the latest as of today. When I try and run this, we'll get some good errors telling us what's going on.
Middleware is no longer bundled. What that means is that this, where the JSON body parser stuff was bundled before, is no longer bundled. That means we will need to "npm install body-parser." We will need to require body-parser, and then, where we used this middleware before, we'll replace that with body-parser and invoke it.
Now, if we run this, everything is up and running. Looks like everything is working fine.
The other major feature to talk about that we've covered so far is that instead of using get and post on this people route and defining it twice, I can instead say app.route and then call get and post on that, because app.route now returns a router.
We'll format that and delete this, delete the string. This now, if I rerun, will work just fine as well. This wouldn't have worked before. It's a new feature we're calling app.route. Passing it a string will let you chain these together -- get, post, and whatnot.
There are some other things that have changed. App.router is removed and app.configure is removed. But we never got to that stuff, so I'm not going to worry about it here. We're simply going to focus on what Express 4 does provide moving forward.
Lastly, there is a migration guide on Express's GitHub page. Head over to this link if you're curious about what other minor things have changed for this release.