index.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { initializeApp } from "firebase/app"
  2. import { initAnalytics } from "./analytics"
  3. import { initAuth } from "./auth"
  4. import { initCollections } from "./collections"
  5. import { initEnvironments } from "./environments"
  6. import { initHistory } from "./history"
  7. import { initSettings } from "./settings"
  8. const firebaseConfig = {
  9. apiKey: process.env.API_KEY,
  10. authDomain: process.env.AUTH_DOMAIN,
  11. databaseURL: process.env.DATABASE_URL,
  12. projectId: process.env.PROJECT_ID,
  13. storageBucket: process.env.STORAGE_BUCKET,
  14. messagingSenderId: process.env.MESSAGING_SENDER_ID,
  15. appId: process.env.APP_ID,
  16. measurementId: process.env.MEASUREMENT_ID,
  17. }
  18. let initialized = false
  19. export function initializeFirebase() {
  20. if (!initialized) {
  21. try {
  22. initializeApp(firebaseConfig)
  23. initAuth()
  24. initSettings()
  25. initCollections()
  26. initHistory()
  27. initEnvironments()
  28. initAnalytics()
  29. initialized = true
  30. } catch (e) {
  31. // initializeApp throws exception if we reinitialize
  32. initialized = true
  33. }
  34. }
  35. }