refactored server code to be more modular, added authentication middleware to user creation