The logic in installMiddleware is broken in Express 4.x.

In Express 3.x, all the app.get/post/... handlers are grouped into one middleware app.router. In Express 4.x, app.get/post/... will be the same as app.use(). As a result, the installMiddleware needs to split the handlers for pre-routing and post-routing.