Refactor mongodb connection

This refactoring to mongodb connection handling will solve:
1. username or password with special chars like @ won't be handled correctly to connect to mongodb via the connection string uri, so this refactor solves that
2. exit on mongodb error instead of hang the nodejs app idle