Made callback to app.attachMiddlewares optional.