Add Mongo connection middleware