Rebuilt server.js to use promises.