major rewrite to replace mongoose with CocoaHTTPServer