diff --git a/.gitignore b/.gitignore index 59a6fd6a59..d044cf4682 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,3 @@ dist-ssr # Environment files .env -firebase.json diff --git a/backend/question-service/.env.sample b/backend/question-service/.env.sample new file mode 100644 index 0000000000..0464148161 --- /dev/null +++ b/backend/question-service/.env.sample @@ -0,0 +1,6 @@ +MONGO_URI=MONGO_URI + +FIREBASE_PROJECT_ID=FIREBASE_PROJECT_ID +FIREBASE_PRIVATE_KEY=-FIREBASE_PRIVATE_KEY +FIREBASE_CLIENT_EMAIL=FIREBASE_CLIENT_EMAIL +FIREBASE_STORAGE_BUCKET=FIREBASE_STORAGE_BUCKET diff --git a/backend/question-service/config/firebase.ts b/backend/question-service/config/firebase.ts index 73ac0bf372..5ff9b8b053 100644 --- a/backend/question-service/config/firebase.ts +++ b/backend/question-service/config/firebase.ts @@ -1,9 +1,12 @@ import admin from "firebase-admin"; -import serviceAccount from "../firebase.json"; admin.initializeApp({ - credential: admin.credential.cert(serviceAccount as admin.ServiceAccount), - storageBucket: "gs://peerprep-c3bd1.appspot.com", + credential: admin.credential.cert({ + projectId: process.env.FIREBASE_PROJECT_ID, + privateKey: process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, "\n"), + clientEmail: process.env.FIREBASE_CLIENT_EMAIL, + } as admin.ServiceAccount), + storageBucket: process.env.FIREBASE_STORAGE_BUCKET, }); const bucket = admin.storage().bucket();