Refactoring in preparations for push

Extracting endpoints from api app, adding mongo authentication