Skip to content

Commit fdee2f1

Browse files
committed
refactor: rename server only getAdminApp to avoid confusion with firebase sdk
1 parent 7ffdbce commit fdee2f1

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

packages/nuxt/src/runtime/admin/plugin.server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { App as AdminApp } from 'firebase-admin/app'
2-
import { getAdminApp } from 'vuefire/server'
2+
import { ensureAdminApp } from 'vuefire/server'
33
import { defineNuxtPlugin, useRequestEvent, useRuntimeConfig } from '#app'
44

55
export default defineNuxtPlugin(() => {
66
const event = useRequestEvent()
77
const { vuefire } = useRuntimeConfig()
88

9-
const firebaseAdminApp = getAdminApp(vuefire?.options?.admin?.options)
9+
const firebaseAdminApp = ensureAdminApp(vuefire?.options?.admin?.options)
1010

1111
// TODO: Is this accessible within middlewares and api routes? or should we use a middleware to add it
1212
event.context.firebaseApp = firebaseAdminApp

packages/nuxt/src/runtime/auth/api.session-verification.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
deleteCookie,
88
setResponseStatus,
99
} from 'h3'
10-
import { getAdminApp } from 'vuefire/server'
10+
import { ensureAdminApp } from 'vuefire/server'
1111
import { logger } from '../logging'
1212
import { useRuntimeConfig } from '#imports'
1313

@@ -19,7 +19,7 @@ export default defineEventHandler(async (event) => {
1919
const { token } = await readBody<{ token?: string }>(event)
2020
const { vuefire } = useRuntimeConfig()
2121

22-
const adminApp = getAdminApp(
22+
const adminApp = ensureAdminApp(
2323
{
2424
projectId: vuefire?.options?.config?.projectId,
2525
...vuefire?.options?.admin?.options,

src/server/admin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import { logger } from './logging'
1212
const FIREBASE_ADMIN_APP_NAME = 'vuefire-admin'
1313

1414
/**
15-
* Setups a Firebase Admin App
15+
* Setups a Firebase Admin App or reuses it
1616
*
1717
* @param firebaseAdminOptions - options to pass to the admin app
1818
* @param name - name of the app
1919
* @experimental this is experimental and may change in the future
2020
*/
21-
export function getAdminApp(
21+
export function ensureAdminApp(
2222
firebaseAdminOptions?: Omit<AppOptions, 'credential'>,
2323
name = FIREBASE_ADMIN_APP_NAME
2424
) {

src/server/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ensureAdminApp } from './admin'
12
export { VueFireAppCheckServer } from './app-check'
23
export {
34
VueFireAuthServer,
@@ -6,5 +7,9 @@ export {
67
decodeSessionCookie,
78
decodeUserToken,
89
} from './auth'
9-
export { getAdminApp } from './admin'
10+
export { ensureAdminApp } from './admin'
11+
/**
12+
* @deprecated use `ensureAdminApp` instead.
13+
*/
14+
export const getAdminApp = ensureAdminApp
1015
export { isFirebaseError } from './utils'

0 commit comments

Comments
 (0)