77 defineNuxtModule ,
88} from '@nuxt/kit'
99import type { NuxtModule } from '@nuxt/schema'
10- import { type FirebaseOptions } from '@firebase/app-types'
10+ import type { FirebaseOptions } from '@firebase/app-types'
11+ import type { NuxtVueFireAppCheckOptions } from './app-check'
1112
1213export interface VueFireNuxtModuleOptions {
1314 /**
@@ -17,19 +18,22 @@ export interface VueFireNuxtModuleOptions {
1718 */
1819 optionsApiPlugin ?: boolean | 'firestore' | 'database'
1920
20- config : FirebaseOptions
21+ config ? : FirebaseOptions
2122
2223 /**
2324 * Optional name passed to `firebase.initializeApp(config, name)`
2425 */
2526 appName ?: string
2627
27- services ?: {
28- auth ?: boolean
29- firestore ?: boolean
30- database ?: boolean
31- storage ?: boolean
32- }
28+ /**
29+ * Enables AppCheck
30+ */
31+ appCheck ?: NuxtVueFireAppCheckOptions
32+
33+ /**
34+ * Enables Authentication
35+ */
36+ auth ?: boolean
3337}
3438
3539// Manual to avoid build error
@@ -45,11 +49,16 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
4549
4650 defaults : {
4751 optionsApiPlugin : false ,
48- config : { } ,
49- services : { } ,
5052 } ,
5153
5254 setup ( options , nuxt ) {
55+ // ensure provided options are valid
56+ if ( ! options . config ) {
57+ throw new Error (
58+ '[VueFire]: Missing firebase config. Provide a "config" option to the VueFire module options.'
59+ )
60+ }
61+
5362 const { resolve } = createResolver ( import . meta. url )
5463 const runtimeDir = fileURLToPath ( new URL ( './runtime' , import . meta. url ) )
5564 const templatesDir = fileURLToPath (
@@ -58,12 +67,7 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
5867
5968 // Let plugins and the user access the firebase config within the app
6069 nuxt . options . appConfig . firebaseConfig = options . config
61-
62- if ( Object . keys ( options . config ) . length === 0 ) {
63- throw new Error (
64- '[VueFire]: Missing firebase config. Provide it to the VueFire module options.'
65- )
66- }
70+ nuxt . options . appConfig . appCheck = options . appCheck
6771
6872 // nuxt.options.build.transpile.push(templatesDir)
6973 nuxt . options . build . transpile . push ( runtimeDir )
@@ -83,12 +87,22 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
8387 } )
8488
8589export default VueFire
90+ export type {
91+ NuxtVueFireAppCheckOptions ,
92+ NuxtVueFireAppCheckOptionsReCaptchaV3 ,
93+ NuxtVueFireAppCheckOptionsReCaptchaEnterprise ,
94+ } from './app-check'
8695
8796declare module '@nuxt/schema' {
8897 export interface AppConfig {
8998 /**
9099 * Firebase config to initialize the app.
91100 */
92101 firebaseConfig : FirebaseOptions
102+
103+ /**
104+ * AppCheck options passed to VueFire module.
105+ */
106+ appCheck ?: NuxtVueFireAppCheckOptions
93107 }
94108}
0 commit comments