DockerSpace / frontend /src /firebase.ts
DennisChan0909's picture
Remove Google login from frontend
1e7800b
Raw
History Blame Contribute Delete
1.14 kB
import { initializeApp, FirebaseApp } from 'firebase/app'
import { getAuth, Auth } from 'firebase/auth'
import { getFirestore, Firestore } from 'firebase/firestore'
const apiKey = import.meta.env.VITE_FIREBASE_API_KEY as string | undefined
const authDomain = import.meta.env.VITE_FIREBASE_AUTH_DOMAIN as string | undefined
const projectId = import.meta.env.VITE_FIREBASE_PROJECT_ID as string | undefined
// True only when all required env vars are present
export const firebaseReady = !!(apiKey && authDomain && projectId)
let app: FirebaseApp | null = null
let _auth: Auth | null = null
let _db: Firestore | null = null
if (firebaseReady) {
app = initializeApp({
apiKey,
authDomain,
projectId,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET as string | undefined,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID as string | undefined,
appId: import.meta.env.VITE_FIREBASE_APP_ID as string | undefined,
})
_auth = getAuth(app)
_db = getFirestore(app)
}
export const auth = _auth!
export const db = _db!