Refactor server.js.