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-02-26 20:55:17 -08:00
|
|
|
let cacheInfo = cache.apps.get(applicationId);
|
|
|
|
|
if (!cacheInfo) {
|
2016-02-20 12:25:43 -05:00
|
|
|
return;
|
|
|
|
|
}
|
2016-02-09 19:31:23 -08:00
|
|
|
|
2016-02-20 12:25:43 -05:00
|
|
|
this.applicationId = applicationId;
|
|
|
|
|
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 20:55:17 -08:00
|
|
|
this.database = DatabaseAdapter.getDatabaseConnection(applicationId, cacheInfo.collectionPrefix);
|
2016-02-16 23:43:09 -08:00
|
|
|
|
2016-02-25 19:04:27 -05:00
|
|
|
this.serverURL = cacheInfo.serverURL;
|
2016-02-16 23:43:09 -08:00
|
|
|
this.verifyUserEmails = cacheInfo.verifyUserEmails;
|
|
|
|
|
this.appName = cacheInfo.appName;
|
|
|
|
|
|
2016-02-05 14:38:09 -05:00
|
|
|
this.hooksController = cacheInfo.hooksController;
|
2016-02-20 12:25:43 -05:00
|
|
|
this.filesController = cacheInfo.filesController;
|
2016-02-16 23:43:09 -08:00
|
|
|
this.pushController = cacheInfo.pushController;
|
2016-02-20 13:02:22 -05:00
|
|
|
this.loggerController = cacheInfo.loggerController;
|
2016-02-27 10:51:12 -05:00
|
|
|
this.userController = cacheInfo.userController;
|
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-25 19:04:27 -05:00
|
|
|
|
|
|
|
|
get invalidLinkURL() {
|
|
|
|
|
return `${this.serverURL}/apps/invalid_link.html`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get verifyEmailSuccessURL() {
|
|
|
|
|
return `${this.serverURL}/apps/verify_email_success.html`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get choosePasswordURL() {
|
2016-02-27 14:46:29 -05:00
|
|
|
return `${this.serverURL}/apps/choose_password`;
|
2016-02-27 10:51:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get requestResetPasswordURL() {
|
|
|
|
|
return `${this.serverURL}/apps/${this.applicationId}/request_password_reset`;
|
2016-02-25 19:04:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get passwordResetSuccessURL() {
|
|
|
|
|
return `${this.serverURL}/apps/password_reset_success.html`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get verifyEmailURL() {
|
|
|
|
|
return `${this.serverURL}/apps/${this.applicationId}/verify_email`;
|
|
|
|
|
}
|
|
|
|
|
};
|
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;
|