-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebaseConfig.js
39 lines (36 loc) · 1.09 KB
/
firebaseConfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import firebase from "firebase/compat/app";
import "firebase/compat/firestore";
import "firebase/compat/auth";
import "firebase/compat/storage";
const firebaseConfig = {
apiKey: "AIzaSyCdjuKe_DkpM9PT71WMfl7l3SVpCeZfD5c",
authDomain: "mobilitymate-a8b53.firebaseapp.com",
projectId: "mobilitymate-a8b53",
storageBucket: "mobilitymate-a8b53.appspot.com",
messagingSenderId: "911524752185",
appId: "1:911524752185:web:928da1ee8a528a348356e8",
};
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
} else {
firebase.app();
}
export const db = firebase.firestore();
export const auth = firebase.auth();
export const storage = firebase.storage();
export async function getCurrentUser() {
return new Promise((resolve, reject) => {
if (auth.currentUser) {
resolve(auth.currentUser);
return;
}
// The user is not found, hence listen to the change
const removeListener = auth.onAuthStateChanged((user) => {
removeListener();
resolve(user);
}, reject);
});
}
export function getDateString() {
return new Date().toISOString().split("T")[0];
}