import { initializeApp, cert } from 'firebase-admin/app';
import { getFirestore } from 'firebase-admin/firestore';
import { getMessaging } from 'firebase-admin/messaging';
import { getAuth } from 'firebase-admin/auth'

const config = useRuntimeConfig()

export const app = initializeApp({
  credential: cert({
    "project_id": "wrbapp",
    "private_key_id": config.privateKeyId,
    "private_key": config.privateKey, 
    "client_email": "firebase-adminsdk-iqgyy@wrbapp.iam.gserviceaccount.com",
    "client_id": config.clientId,
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-iqgyy%40wrbapp.iam.gserviceaccount.com"
  })
})

export const firestore = getFirestore()

export const db = getFirestore();
export const messaging = getMessaging();
export const auth = getAuth()
