diff --git a/packages/nestjs-firebase/src/firebase.interface.ts b/packages/nestjs-firebase/src/firebase.interface.ts index 6f21b675..a25baa2b 100644 --- a/packages/nestjs-firebase/src/firebase.interface.ts +++ b/packages/nestjs-firebase/src/firebase.interface.ts @@ -26,6 +26,7 @@ export interface FirebaseAdmin { auth: firebaseAdmin.auth.Auth; messaging: firebaseAdmin.messaging.Messaging; firestore: firebaseAdmin.firestore.Firestore; + database?: firebaseAdmin.database.Database; storage: firebaseAdmin.storage.Storage; remoteConfig: firebaseAdmin.remoteConfig.RemoteConfig; } diff --git a/packages/nestjs-firebase/src/util/getFirebaseAdmin.ts b/packages/nestjs-firebase/src/util/getFirebaseAdmin.ts index 304f3813..208f022b 100644 --- a/packages/nestjs-firebase/src/util/getFirebaseAdmin.ts +++ b/packages/nestjs-firebase/src/util/getFirebaseAdmin.ts @@ -1,10 +1,14 @@ import * as admin from "firebase-admin"; import { FirebaseAdmin, FirebaseModuleOptions } from "../firebase.interface"; -const createInstances = (app: admin.app.App): FirebaseAdmin => ({ +const createInstances = ( + app: admin.app.App, + initDatabase = false, +): FirebaseAdmin => ({ auth: app.auth(), messaging: app.messaging(), firestore: app.firestore(), + database: initDatabase ? app.database() : undefined, storage: app.storage(), remoteConfig: app.remoteConfig(), }); @@ -24,5 +28,6 @@ export const getFirebaseAdmin = ( : undefined, ...appOptions, }), + !!appOptions.databaseURL, ); };