refactored server.js and extracted config to separate files