-
Notifications
You must be signed in to change notification settings - Fork 1
/
firebase.js
33 lines (27 loc) · 1.05 KB
/
firebase.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
import * as firebase from "firebase";
if (process.env.NODE_ENV !== "production") require("./secrets");
const FIRESTORE_API_KEY = process.env.FIRESTORE_API_KEY;
const FIRESTORE_AUTH_DOMAIN = process.env.FIRESTORE_AUTH_DOMAIN;
const FIRESTORE_DATABASE_URL = process.env.FIRESTORE_DATABASE_URL;
const FIRESTORE_PROJECT_ID = process.env.FIRESTORE_PROJECT_ID;
const FIRESTORE_STORAGE_BUCKET = process.env.FIRESTORE_STORAGE_BUCKET;
const FIRESTORE_MESSAGING_SENDER_ID = process.env.FIRESTORE_MESSAGING_SENDER_ID;
const FIRESTORE_APP_ID = process.env.FIRESTORE_APP_ID;
const firebaseConfig = {
apiKey: FIRESTORE_API_KEY,
authDomain: FIRESTORE_AUTH_DOMAIN,
databaseURL: FIRESTORE_DATABASE_URL,
projectId: FIRESTORE_PROJECT_ID,
storageBucket: FIRESTORE_STORAGE_BUCKET,
messagingSenderId: FIRESTORE_MESSAGING_SENDER_ID,
appId: FIRESTORE_APP_ID,
};
let app;
if (firebase.apps.length === 0) {
app = firebase.initializeApp(firebaseConfig);
} else {
app = firebase.app();
}
const auth = firebase.auth();
const db = firebase.firestore();
export { auth, db, firebase };