10 examples of 'firebase.initializeapp(config)' in JavaScript

Every line of 'firebase.initializeapp(config)' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
229export function firebaseInit(config: any) {
230 firebase.initializeApp(config);
231}
11function initialize(config) {
12 if (firebase.apps.length > 0) {
13 // No need to inititalize again
14 return;
15 }
16
17 // Initialize for the first time
18 firebase.initializeApp({
19 credential: firebase.credential.cert(config.serviceAccount),
20 databaseURL: 'https://' + config.serviceAccount.project_id + '.firebaseio.com'
21 });
22}
9function initialize (config) {
10 if (firebase.apps.length > 0) {
11 // No need to inititalize again
12 return
13 }
14
15 // Initialize for the first time
16 firebase.initializeApp({
17 credential: firebase.credential.cert(config.serviceAccount),
18 databaseURL: 'https://' + config.serviceAccount.project_id + '.firebaseio.com'
19 })
20}
25initializeApp(config) {
26 this.add.initializeApp(config);
27 return this;
28}
59initializeFirebase(config: any) {
60 firebase.initializeApp(config);
61}
25private initFirebase(){
26 const config = Configuration.getConfig("firebase");
27 if (config && firebase.apps.length === 0) {
28 return firebase.initializeApp(config);
29 }
30}
52_initializeApp(native = false) {
53 if (native) {
54 // for apps already initialized natively that
55 // we have info from RN constants
56 this._initialized = true;
57 this._nativeInitialized = true;
58 } else {
59 FirebaseCoreModule.initializeApp(this._name, this._options, (error, result) => {
60 this._initialized = true;
61 INTERNALS.SharedEventEmitter.emit(`AppReady:${this._name}`, { error, result });
62 });
63 }
64}
113function initializeApp(
114 accessToken?: string,
115 databaseName?: string,
116 projectId?: string
117): firebase.app.App {
118 let appOptions = {};
119 if (databaseName) {
120 appOptions['databaseURL'] = `http://${DATABASE_ADDRESS}?ns=${databaseName}`;
121 }
122 if (projectId) {
123 appOptions['projectId'] = projectId;
124 }
125 const appName = 'app-' + new Date().getTime() + '-' + Math.random();
126 let app = firebase.initializeApp(appOptions, appName);
127 // hijacking INTERNAL.getToken to bypass FirebaseAuth and allows specifying of auth headers
128 if (accessToken) {
129 (app as any).INTERNAL.getToken = () =>
130 Promise.resolve({ accessToken: accessToken });
131 }
132 if (databaseName) {
133 // Toggle network connectivity to force a reauthentication attempt.
134 // This mitigates a minor race condition where the client can send the
135 // first database request before authenticating.
136 app.database().goOffline();
137 app.database().goOnline();
138 }
139 if (projectId) {
140 app.firestore().settings({
141 host: FIRESTORE_ADDRESS,
142 ssl: false
143 });
144 }
145 /**
146 Mute warnings for the previously-created database and whatever other
147 objects were just created.
148 */
149 setLogLevel(LogLevel.ERROR);
150 return app;
151}
24async init(firebase, firebaseConfig) {
25 this.phrases = [];
26 this._phrases = [];
27 this.users = [];
28 this._users = [];
29 this.holidays = [];
30 this.weekendDays = [];
31 this.standupUrl = '';
32 this.firebase = firebase;
33 this.firebase.initializeApp(firebaseConfig);
34 this.database = await this.firebase.database();
35 moment.locale(this.locale || 'PL');
36 await this.connectDb(firebaseConfig);
37 await this.fetchData();
38 this.runSchedule();
39}
185function FirebaseApp(options, name, firebaseInternals_) {
186 var _this = this;
187 this.firebaseInternals_ = firebaseInternals_;
188 this.services_ = {};
189 this.isDeleted_ = false;
190 this.name_ = name;
191 this.options_ = deep_copy_1.deepCopy(options);
192 if (typeof this.options_ !== 'object' || this.options_ === null) {
193 // Ensure the options are a non-null object
194 this.options_ = {};
195 }
196 var hasCredential = ('credential' in this.options_);
197 var errorMessage;
198 if (!hasCredential) {
199 errorMessage = 'Options must be an object containing at least a "credential" property.';
200 }
201 var credential = this.options_.credential;
202 if (typeof credential !== 'object' || credential === null || typeof credential.getAccessToken !== 'function') {
203 errorMessage = 'The "credential" property must be an object which implements the Credential interface.';
204 }
205 if (typeof errorMessage !== 'undefined') {
206 throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, "Invalid Firebase app options passed as the first argument to initializeApp() for the " +
207 ("app named \"" + this.name_ + "\". " + errorMessage));
208 }
209 Object.keys(firebaseInternals_.serviceFactories).forEach(function (serviceName) {
210 // Defer calling createService() until the service is accessed
211 _this[serviceName] = _this.getService_.bind(_this, serviceName);
212 });
213 this.INTERNAL = new FirebaseAppInternals(this.options_.credential);
214}

Related snippets