Refactor of server.js complete