Refactoring server with nodeJS