-
Notifications
You must be signed in to change notification settings - Fork 5
/
firebase.js
40 lines (34 loc) · 1.4 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
34
35
36
37
38
39
40
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import {
getAuth,
signInWithPopup,
GoogleAuthProvider,
signInWithEmailAndPassword,
createUserWithEmailAndPassword,
} from "firebase/auth";
import { getStorage, ref, uploadBytes } from "firebase/storage";
const firebaseConfig = {
apiKey:
process.env.NEXT_PUBLIC_FIREBASE_API_KEY || "AMBIENTE_DE_DESENVOLVIMENTO",
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
};
const firebaseApp = initializeApp(firebaseConfig);
export const db = getFirestore(firebaseApp);
const provider = new GoogleAuthProvider();
const storage = getStorage();
const storageRef = ref(storage, `fotos-${Date.now()}`);
provider.setCustomParameters({
prompt: "select_account ",
});
export const auth = getAuth(firebaseApp);
export const signInWithGooglePopup = () => signInWithPopup(auth, provider);
export const signInWithEmailESenha = (email, senha) =>
signInWithEmailAndPassword(auth, email, senha);
export const createUserWithEmailESenha = (email, senha) =>
createUserWithEmailAndPassword(auth, email, senha);
export const uploadFoto = (file) => uploadBytes(storageRef, file);