@redredgroup/nestjs-firebase-admin
v1.1.2
Published
Firebase Admin integration to a NestJS application
Downloads
260
Maintainers
Readme
Nestjs Firebase Admin
Important
Versions 1.0.2 and earlier are deprecated! for older versions, use the (README.md)deprecated It is recommended that you use the latest version of package whenever possible.
Support Function
| Function | Support | | -------------- | ------- | | Authentication | ✅ | | Database | ✅ | | Firestore | ✅ | | Messaging | ✅ | | RemoteConfig | ✅ | | Storage | ✅ |
Introduction
This package is a module that converts the asynchronous firebase-admin to Nestjs.
Installation
using npm
npm install @redredgroup/nestjs-firebase-admin
using yarn
yarn install @redredgroup/nestjs-firebase-admin
using pnpm
pnpm add @redredgroup/nestjs-firebase-admin
Import module
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { FirebaseAdminModule } from '@redredgroup/nestjs-firebase-admin';
@Module({
imports: [
FirebaseAdminModule.forRoot({
firebaseAdminOptions: {}, //firebase admin option
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
//Or the forRootAsync module using @nestjs/Config
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { FirebaseAdminModule } from '@redredgroup/nestjs-firebase-admin';
@Module({
imports: [
FirebaseAdminModule.forRootAsync({
useFactory: () => ({ firebaseAdminOptions: {} }), //firebase admin option
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Example
Sending SMS
import { Injectable } from '@nestjs/common';
import { FirebaseAdminService } from '@redredgroup/nestjs-firebase-admin';
@Injectable()
export class AppService {
constructor(private readonly firebaseAdminService: FirebaseAdminService) {}
async getFirebaseUsers(): Promise<string> {
const getFirebaseUsers = await this.firebaseAdminService.Authentication.listUsers();
console.log(getFirebaseUsers);
return 'ok';
}
}
Copyright
© 2023 REDREDGROUP Software. All Right Reserved.
License
Apache-2.0