nestjs-firebase
v12.0.0
Published
@nestjs with firebase
Readme
nestjs-firebase
Firebase Admin integration for NestJS.
Install
npm install nestjs-firebase @nestjs/common firebase-adminUsage
Configure the module with a service account file path (or a service account object):
import { Module } from "@nestjs/common";
import { FirebaseModule } from "nestjs-firebase";
@Module({
imports: [FirebaseModule.forRoot({
googleApplicationCredential: "path/to/service-account.json",
})],
})
export class AppModule {}Inject the Firebase Admin services where needed:
import { Injectable } from "@nestjs/common";
import { FirebaseAdmin, InjectFirebaseAdmin } from "nestjs-firebase";
@Injectable()
export class NotificationsService {
constructor(@InjectFirebaseAdmin() private readonly firebase: FirebaseAdmin) {}
async send(token: string, title: string): Promise<void> {
await this.firebase.messaging.send({ token, notification: { title } });
}
}API
FirebaseModule.forRoot(options)andFirebaseModule.forRootAsync(options)configure Firebase Admin.@InjectFirebaseAdmin()injects the configured Firebase Admin services.- Set
databaseURLin the Firebase options to initialize Realtime Database.
Contributing
Issues and pull requests are welcome at g59/nestjs-plugins.
License
MIT © g59
