()
| 11 | ); |
| 12 | |
| 13 | export function init(): void { |
| 14 | if (!existsSync(SERVICE_ACCOUNT_PATH)) { |
| 15 | if (isDevEnvironment()) { |
| 16 | Logger.warning( |
| 17 | "Firebase service account key not found! Continuing in dev mode, but authentication will throw errors.", |
| 18 | ); |
| 19 | } else if (process.env["BYPASS_FIREBASE"] === "true") { |
| 20 | Logger.warning("BYPASS_FIREBASE is enabled! Running without firebase."); |
| 21 | } else { |
| 22 | throw new MonkeyError( |
| 23 | 500, |
| 24 | "Firebase service account key not found! Make sure generate a service account key and place it in credentials/serviceAccountKey.json.", |
| 25 | "init() firebase-admin.ts", |
| 26 | ); |
| 27 | } |
| 28 | } else { |
| 29 | admin.initializeApp({ |
| 30 | credential: admin.credential.cert(SERVICE_ACCOUNT_PATH), |
| 31 | }); |
| 32 | Logger.success("Firebase app initialized"); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | function get(): typeof admin { |
| 37 | if (admin.apps.length === 0) { |
nothing calls this directly
no test coverage detected