Remove reliance on global state

Review Request #9782 — Created March 15, 2018 and submitted — Latest diff uploaded

Information

rb-gateway
master
d9ade07...

Reviewers

This patch is a cleanup of the API routes. The major change is that we
now have an API type which contains the API methods. With this change,
the routes now have access to the API's configuration so we no longer
need a global Config object!

Additionally, some cleanup has been done to the routes that require a
repository with the api.withRepository middleware, which provides the
requested repository as the "repo" context variable (instead of having
each route retrieve it and do error checking). Routes have been
re-written to have a simpler error-checking flow as well.

Ran unit tests.