Reorganizing app.js to put related initialization steps together
You can always move the require() call for middlewares up. You're not doing anything with the returned value from calling it on app.

var middlewares = require('./middlewares/config');

app.set(.....)

app.use(.....)

middlewares(app)


I'm assuming prototypes does some hacks with the global namespace. If so, then there's not much you can do about it. That's not really good practice though.