A full example for both express 3 and 4 can be found on github.
I have a bunch of routes which are under the same namespace.
I could start implementing these as follows:
But I have a problem.
I’m lazy, so fuck that shit.
In express 3 you had the express-namespace module which could alleviate your problems as follows:
In express 4 the Router class received a rework.
You can now do the following:
Looks more cluttered than the v3 example you say?
Well keep in mind that with this way you can more easily put everything in separate files without passing your app object everywhere.
Express 4 - shorthand
In the previous example we’ve always attached a verb directly to a route, but you can also define a route on it’s own and then attach verbs to that.