Refactoring part-1 of server.js