Refactor server module to support adding to existing Express app instead of running standalone