Skip to content

fix: (0 , __vite_ssr_import_0__.getApps) is not a function #1631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/server/admin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import {
initializeApp as initializeAdminApp,
cert,
getApps as getAdminApps,
applicationDefault,
import { createRequire } from 'node:module'
import type {
App as AdminApp,
AppOptions,
// renamed because there seems to be a global Credential type in vscode
Credential as FirebaseAdminCredential,
AppOptions,
} from 'firebase-admin/app'
import { logger } from './logging'

const require = createRequire(import.meta.url)
const {
initializeApp: initializeAdminApp,
cert,
getApps: getAdminApps,
applicationDefault,
} = require('firebase-admin/app')

const FIREBASE_ADMIN_APP_NAME = 'vuefire-admin'

/**
Expand All @@ -25,7 +31,7 @@ export function ensureAdminApp(
// only initialize the admin sdk once
logger.debug(`Checking if admin app "${name}" exists...`)

if (!getAdminApps().find((app) => app.name === name)) {
if (!getAdminApps().find((app: AdminApp) => app.name === name)) {
const {
// these can be set by the user on other platforms
FIREBASE_PROJECT_ID,
Expand Down Expand Up @@ -120,5 +126,5 @@ export function ensureAdminApp(
}

// we know have a valid admin app
return getAdminApps().find((app) => app.name === name)!
return getAdminApps().find((app: AdminApp) => app.name === name)!
}