Skip to content

Commit

Permalink
Seperate Simulators codes
Browse files Browse the repository at this point in the history
  • Loading branch information
rezahedi committed Mar 16, 2024
1 parent 0da62c4 commit 923b4fb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
17 changes: 17 additions & 0 deletions src/firebase-simulators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Auth, connectAuthEmulator } from "firebase/auth";
import { Firestore, connectFirestoreEmulator } from "firebase/firestore";
import { FirebaseStorage, connectStorageEmulator } from "firebase/storage";

export default function FirebaseSimulators (
{db, auth, storage}:
{db: Firestore, auth: Auth, storage: FirebaseStorage}
){
if( import.meta.env.DEV ) {

// TODO: Check if simulators are running

connectFirestoreEmulator(db, "localhost", 8080)
connectAuthEmulator(auth, "http://127.0.0.1:9099");
connectStorageEmulator(storage, "localhost", 9199)
}
}
14 changes: 6 additions & 8 deletions src/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAuth, connectAuthEmulator } from "firebase/auth";
import { getFirestore, connectFirestoreEmulator } from "firebase/firestore";
import { getStorage, connectStorageEmulator } from "firebase/storage";
import { getAuth } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
import { getStorage } from "firebase/storage";
// import FirebaseSimulators from "./firebase-simulators";

// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

Expand All @@ -22,8 +24,4 @@ export const db = getFirestore(app);
export const auth = getAuth(app);
export const storage = getStorage(app);

if( import.meta.env.DEV ) {
connectFirestoreEmulator(db, "localhost", 8080)
connectAuthEmulator(auth, "http://127.0.0.1:9099");
connectStorageEmulator(storage, "localhost", 9199)
}
// FirebaseSimulators({db, auth, storage})

0 comments on commit 923b4fb

Please sign in to comment.