Pass object to middleware

Middleware expects a object i.e connect. So we could opt to change the middleware instead and may make more sense to.