mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-22 00:06:16 +08:00
firebase auth can be undefined
This commit is contained in:
parent
e23c10d597
commit
16c7750a01
|
@ -2,17 +2,22 @@
|
|||
import { FirebaseApp, initializeApp } from "firebase/app";
|
||||
import { getAuth, Auth as AuthType } from "firebase/auth";
|
||||
import { firebaseConfig } from "./constants/firebase-config"; // eslint-disable-line require-path-exists/exists
|
||||
import * as Notifications from "./elements/notifications";
|
||||
|
||||
// Initialize Firebase
|
||||
export let app: FirebaseApp;
|
||||
export let Auth: AuthType;
|
||||
export let app: FirebaseApp | undefined;
|
||||
export let Auth: AuthType | undefined;
|
||||
|
||||
try {
|
||||
app = initializeApp(firebaseConfig);
|
||||
Auth = getAuth(app);
|
||||
// throw new Error("Firebase is not initialized");
|
||||
} catch (e) {
|
||||
app = undefined;
|
||||
Auth = undefined;
|
||||
console.error(e);
|
||||
$("body").text(
|
||||
"Failed to initialize Firebase. Are you sure you have the correct config in the firebase-config.ts file?"
|
||||
);
|
||||
Notifications.addBanner("Offline mode", 0, undefined, true);
|
||||
// $("body").text(
|
||||
// "Failed to initialize Firebase. Are you sure you have the correct config in the firebase-config.ts file?"
|
||||
// );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue