Download src/firebase.ts from Musabek/BilimWay: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/spaces/Musabek/BilimWay/resolve/main/src/firebase.ts
- Command line
-
hf download hf://spaces/Musabek/BilimWay/src/firebase.ts
-
curl -L -o firebase.ts https://huggingface.co/spaces/Musabek/BilimWay/resolve/main/src/firebase.ts
1.41 kB
| import { initializeApp, getApp, getApps } from "firebase/app"; | |
| import { getAuth, GoogleAuthProvider, signInWithPopup, signOut } from "firebase/auth"; | |
| import { initializeFirestore, getFirestore, persistentLocalCache, persistentMultipleTabManager } from "firebase/firestore"; | |
| import { getStorage } from "firebase/storage"; | |
| import firebaseConfig from "../firebase-applet-config.json"; | |
| // Initialize Firebase safely | |
| const app = getApps().length === 0 ? initializeApp(firebaseConfig) : getApp(); | |
| export const auth = getAuth(app); | |
| export const storage = getStorage(app); | |
| let firestoreDb; | |
| try { | |
| firestoreDb = initializeFirestore(app, { | |
| localCache: persistentLocalCache({ | |
| tabManager: persistentMultipleTabManager() | |
| }), | |
| ignoreUndefinedProperties: true | |
| }, firebaseConfig.firestoreDatabaseId); | |
| } catch (e) { | |
| console.warn("Firestore with persistence initialization failed, falling back to basic Firestore:", e); | |
| try { | |
| firestoreDb = initializeFirestore(app, { | |
| ignoreUndefinedProperties: true | |
| }, firebaseConfig.firestoreDatabaseId); | |
| } catch (err) { | |
| firestoreDb = getFirestore(app, firebaseConfig.firestoreDatabaseId); | |
| } | |
| } | |
| export const db = firestoreDb; | |
| export const googleProvider = new GoogleAuthProvider(); | |
| // Custom parameters to always prompt for account selection | |
| googleProvider.setCustomParameters({ | |
| prompt: 'select_account' | |
| }); | |
| export { signInWithPopup, signOut }; | |