Refactored server (loosely based on yeoman angular-fullstack generator).