Refactoring the server to use promises instead of callbacks