Configuration - mongodb/mlab-data-api GitHub Wiki
-
MLAB_DATA_API_KEY
: API key required to authenticate all requests -
MLAB_DATA_API_CONFIG
: Configuration string or path to a file containing the configuration -
PORT
: Network port on which to listen for requests
The MLAB_DATA_API_CONFIG
environment variable must contain a string with the configuration
settings or the name of a file containing said configuration. The configuration may be
specified in either YAML or JSON format. Most users may find that YAML is more convenient
when using a file and JSON is more convenient when specifying the configuration inline.
Example (YAML):
port: 8080
clusters:
rs-ds0000000: mongodb://user:[email protected]:27001/admin
rs-ds1111111: mongodb://user:[email protected]:27001/admin
databases:
foo: mongodb://user:[email protected]:27001/foo
bar: mongodb://user:[email protected]:27001/bar
Example (JSON):
{
port: 8080,
clusters: {
"rs-ds0000000": "mongodb://user:[email protected]:27001/admin",
"rs-ds1111111": "mongodb://user:[email protected]:27001/admin"
},
databases: {
foo: "mongodb://user:[email protected]:27001/foo",
bar: "mongodb://user:[email protected]:27001/bar"
}
}
-
port
: The network port on which to listen for requests. Omit this field if you are using thePORT
environment variable (e.g. when self-hosting the API on Heroku) -
clusters
: Mapping of cluster ID to authenticated MongoDB URI. If the specified credentials are for theadmin
database, the API will allow access to all databases in the cluster. Otherwise, the API will only allow access to the specified database in the URI. The cluster ID is arbitrary and is only used in the URL path as a way to select which cluster to access (e.g./api/1/clusters/<CLUSTER_ID>/databases
). Most users may wish to use the same cluster ID as their existing mLab deployment for consistency. -
databases
: Mapping of database name to authenticated MongoDB URI. This is intended for single database connections, such as mLab Sandbox deployments. The name of the database in the mapping is arbitrary and is only used in the URL path as a way to select which database to access (e.g./api/1/databases/<DB_NAME>/collections
).