Move getStorage() into init.ts after initializeApp() is called.

This commit is contained in:
James Grugett 2022-07-14 11:44:52 -05:00
parent deaa595f07
commit 0c328bc398
2 changed files with 4 additions and 8 deletions

View File

@ -1,5 +1,6 @@
import { getFirestore } from '@firebase/firestore' import { getFirestore } from '@firebase/firestore'
import { initializeApp, getApps, getApp } from 'firebase/app' import { initializeApp, getApps, getApp } from 'firebase/app'
import { getStorage } from 'firebase/storage'
import { FIREBASE_CONFIG } from 'common/envs/constants' import { FIREBASE_CONFIG } from 'common/envs/constants'
import { connectFirestoreEmulator } from 'firebase/firestore' import { connectFirestoreEmulator } from 'firebase/firestore'
import { connectFunctionsEmulator, getFunctions } from 'firebase/functions' import { connectFunctionsEmulator, getFunctions } from 'firebase/functions'
@ -8,6 +9,7 @@ import { connectFunctionsEmulator, getFunctions } from 'firebase/functions'
export const app = getApps().length ? getApp() : initializeApp(FIREBASE_CONFIG) export const app = getApps().length ? getApp() : initializeApp(FIREBASE_CONFIG)
export const db = getFirestore() export const db = getFirestore()
export const functions = getFunctions() export const functions = getFunctions()
export const storage = getStorage()
declare global { declare global {
/* eslint-disable-next-line no-var */ /* eslint-disable-next-line no-var */

View File

@ -1,11 +1,5 @@
import { import { ref, uploadBytesResumable, getDownloadURL } from 'firebase/storage'
getStorage, import { storage } from './init'
ref,
uploadBytesResumable,
getDownloadURL,
} from 'firebase/storage'
const storage = getStorage()
// TODO: compress large images // TODO: compress large images
export const uploadImage = async ( export const uploadImage = async (