-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cross device syncing with firebase (#404)
- Loading branch information
Showing
15 changed files
with
2,023 additions
and
170 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { initializeApp } from "firebase/app"; | ||
import { getAuth } from "firebase/auth"; | ||
import { getFirestore } from "firebase/firestore"; | ||
|
||
|
||
const firebaseConfig = { | ||
apiKey: "AIzaSyAu3LZ0FZFTDukUmgsJlr6U_0KxBx34uBo", | ||
authDomain: "nthumods-prod.firebaseapp.com", | ||
projectId: "nthumods-prod", | ||
storageBucket: "nthumods-prod.appspot.com", | ||
messagingSenderId: "977252315806", | ||
appId: "1:977252315806:web:e7fcf9992f1b916c2c018f", | ||
measurementId: "G-D06ZGLBZR3" | ||
}; | ||
|
||
// Initialize Firebase | ||
const app = initializeApp(firebaseConfig); | ||
export const auth = getAuth(app); | ||
export const db = getFirestore(app); | ||
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { initializeApp, getApps, cert } from "firebase-admin/app"; | ||
import { getAuth } from "firebase-admin/auth"; | ||
import { getFirestore } from "firebase-admin/firestore"; | ||
|
||
const serviceAccountBase64 = process.env.FIREBASE_SERVICE_ACCOUNT; | ||
if(!serviceAccountBase64) throw new Error('FIREBASE_SERVICE_ACCOUNT is required'); | ||
const serviceAccount = JSON.parse(Buffer.from(serviceAccountBase64, 'base64').toString()); | ||
|
||
export const admin = | ||
getApps().find((it) => it.name === "firebase-admin-app") || | ||
initializeApp( | ||
{ | ||
credential: cert(serviceAccount), | ||
}, | ||
"firebase-admin-app" | ||
); | ||
export const adminAuth = getAuth(admin); | ||
export const adminFirestore = getFirestore(admin); |
Oops, something went wrong.