Skip to content

Commit

Permalink
Merge pull request #1728 from g59/next
Browse files Browse the repository at this point in the history
chore: firebase ability to use Realtime Database
  • Loading branch information
9renpoto authored Oct 22, 2023
2 parents 181c068 + 5e80b73 commit 9cd3e71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/nestjs-firebase/src/firebase.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 6 additions & 1 deletion packages/nestjs-firebase/src/util/getFirebaseAdmin.ts
Original file line number Diff line number Diff line change
@@ -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(),
});
Expand All @@ -24,5 +28,6 @@ export const getFirebaseAdmin = (
: undefined,
...appOptions,
}),
!!appOptions.databaseURL,
);
};

0 comments on commit 9cd3e71

Please sign in to comment.