This commit is contained in:
schmelczerandras 2020-11-04 16:01:17 +01:00
parent 1ce961d6c2
commit 99cdb62928
76 changed files with 340 additions and 433 deletions

View file

@ -0,0 +1,42 @@
import firebase from 'firebase/app';
import 'firebase/firebase-remote-config';
export abstract class Configuration {
private static remoteConfig: firebase.remoteConfig.RemoteConfig;
private static initialized = false;
public static async initialize(): Promise<void> {
if (this.initialized) {
return;
}
const firebaseConfig = {
apiKey: 'AIzaSyBG85dp-AhaCW-qi_6mu77wDPSipzipIF4',
authDomain: 'decla-red.firebaseapp.com',
projectId: 'decla-red',
appId: '1:635208271441:web:c910843ae7e0549dadda70',
};
firebase.initializeApp(firebaseConfig);
this.remoteConfig = firebase.remoteConfig();
this.remoteConfig.settings = {
minimumFetchIntervalMillis: 0, // todo: 3600 * 1000,
fetchTimeoutMillis: 15 * 1000,
} as any;
await this.remoteConfig.ensureInitialized();
await this.remoteConfig.fetchAndActivate();
this.initialized = true;
}
public static get servers(): Array<string> {
if (!this.initialized) {
throw new Error('Configuration should be initialized');
}
return JSON.parse(this.remoteConfig.getValue('online_servers').asString());
}
}