refactored server.js and pulled code into a config directory