Refactor server.js and add mongoose