rename index.js to server.js; refactor server code with server class