Move server code to server.js file