import { cert, getApps, initializeApp } from "firebase-admin/app";
import { FIRESTORE_CLIENT_EMAIL, FIRESTORE_PRIVATE_KEY } from "../keys";

let firebaseApp = getApps()[0];

if (!firebaseApp)
  firebaseApp = initializeApp({
    credential: cert({
      projectId: "solana-signin",
      privateKey: FIRESTORE_PRIVATE_KEY,
      clientEmail: FIRESTORE_CLIENT_EMAIL,
    }),
  });

export default firebaseApp;

{'avg_line_length': 25.5, 'max_line_length': 72, 'alphanum_fraction': 0.7083333333333334, 'licenses': ['Apache-2.0'], 'repository_name': 'CrossMint/solana-auth', 'path': 'packages/examples/nextjs-starter/utils/firebase.ts', 'size': 408, 'lang': 'TypeScript'}