mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-02-02 01:51:01 -05:00
* add firebase emulator, add registration script, add signup spec * Upgrade firebase emulator and make it pass the E2E tests --------- Co-authored-by: MartinBraquet <martin.braquet@gmail.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import * as admin from 'firebase-admin'
|
|
import {getServiceAccountCredentials} from "shared/firebase-utils";
|
|
import {IS_LOCAL} from "common/hosting/constants";
|
|
import {IS_FIREBASE_EMULATOR} from "common/envs/constants";
|
|
|
|
export const initAdmin = () => {
|
|
|
|
if (IS_LOCAL && IS_FIREBASE_EMULATOR) {
|
|
console.log("Using Firebase Emulator Suite.")
|
|
return admin.initializeApp({
|
|
projectId: "compass-57c3c",
|
|
storageBucket: "compass-130ba-public",
|
|
})
|
|
}
|
|
|
|
if (IS_LOCAL) {
|
|
try {
|
|
const serviceAccount = getServiceAccountCredentials()
|
|
|
|
if (!serviceAccount.project_id) {
|
|
console.debug(`GOOGLE_APPLICATION_CREDENTIALS not set, skipping admin firebase init.`)
|
|
return
|
|
}
|
|
console.debug(`Initializing connection to ${serviceAccount.project_id} Firebase...`)
|
|
return admin.initializeApp({
|
|
projectId: serviceAccount.project_id,
|
|
credential: admin.credential.cert(serviceAccount),
|
|
storageBucket: `${serviceAccount.project_id}.appspot.com`,
|
|
})
|
|
} catch (err) {
|
|
console.error(err)
|
|
}
|
|
}
|
|
|
|
console.debug(`Initializing connection to default Firebase...`)
|
|
return admin.initializeApp()
|
|
} |