refactory the server.js, get ready for websocket feature