2016-01-28 10:58:12 -08:00
|
|
|
// A Config object provides information about how a specific app is
|
|
|
|
|
// configured.
|
|
|
|
|
// mount is the URL for the root of the API; includes http, domain, etc.
|
2016-02-05 14:38:09 -05:00
|
|
|
|
2016-02-24 15:55:11 -05:00
|
|
|
import cache from './cache';
|
|
|
|
|
|
2016-02-20 12:25:43 -05:00
|
|
|
export class Config {
|
2016-02-26 19:50:12 -08:00
|
|
|
constructor(applicationId: string, mount: string) {
|
|
|
|
|
let DatabaseAdapter = require('./DatabaseAdapter');
|
2016-01-28 10:58:12 -08:00
|
|
|
|
2016-02-26 19:50:12 -08:00
|
|
|
let cacheInfo = cache.apps[applicationId];
|
2016-02-20 12:25:43 -05:00
|
|
|
this.valid = !!cacheInfo;
|
|
|
|
|
if (!this.valid) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-02-09 19:31:23 -08:00
|
|
|
|
2016-02-20 12:25:43 -05:00
|
|
|
this.applicationId = applicationId;
|
|
|
|
|
this.collectionPrefix = cacheInfo.collectionPrefix || '';
|
|
|
|
|
this.masterKey = cacheInfo.masterKey;
|
|
|
|
|
this.clientKey = cacheInfo.clientKey;
|
|
|
|
|
this.javascriptKey = cacheInfo.javascriptKey;
|
|
|
|
|
this.dotNetKey = cacheInfo.dotNetKey;
|
|
|
|
|
this.restAPIKey = cacheInfo.restAPIKey;
|
|
|
|
|
this.fileKey = cacheInfo.fileKey;
|
|
|
|
|
this.facebookAppIds = cacheInfo.facebookAppIds;
|
|
|
|
|
this.enableAnonymousUsers = cacheInfo.enableAnonymousUsers;
|
2016-02-26 22:55:39 +08:00
|
|
|
this.allowClientClassCreation = cacheInfo.allowClientClassCreation;
|
2016-02-26 19:50:12 -08:00
|
|
|
this.database = DatabaseAdapter.getDatabaseConnection(applicationId, this.collectionPrefix);
|
2016-02-05 14:38:09 -05:00
|
|
|
this.hooksController = cacheInfo.hooksController;
|
2016-02-20 12:25:43 -05:00
|
|
|
this.filesController = cacheInfo.filesController;
|
|
|
|
|
this.pushController = cacheInfo.pushController;
|
2016-02-20 13:02:22 -05:00
|
|
|
this.loggerController = cacheInfo.loggerController;
|
2016-02-20 12:25:43 -05:00
|
|
|
this.oauth = cacheInfo.oauth;
|
2016-01-28 10:58:12 -08:00
|
|
|
|
2016-02-20 12:25:43 -05:00
|
|
|
this.mount = mount;
|
|
|
|
|
}
|
2016-02-26 19:50:12 -08:00
|
|
|
}
|
2016-01-28 10:58:12 -08:00
|
|
|
|
2016-02-20 12:25:43 -05:00
|
|
|
export default Config;
|
2016-01-28 10:58:12 -08:00
|
|
|
module.exports = Config;
|