Skip to content

uptech/nestjs-firebase-admin

 
 

Repository files navigation

NestJS Module for Firebase Admin SDK

Installation

npm install @uptechworks/nestjs-firebase-admin

Import module

import { Module } from '@nestjs/common';
import { FirebaseAdminModule } from '@uptechworks/nestjs-firebase-admin'
import * as admin from 'firebase-admin'
 
@Module({
  imports: [
    FirebaseAdminModule.forRootAsync({
      useFactory: () => ({
        credential: admin.credential.applicationDefault()
      })
    }),
  ],
})
export class AppModule {}

Example

Inject FirebaseAdminSDK

import { Injectable, Inject } from '@nestjs/common';
import { FIREBASE_ADMIN_INJECT, FirebaseAdminSDK } from '@uptechworks/nestjs-firebase-admin';

@Injectable()
export class AppService {
  constructor(
    @Inject(FIREBASE_ADMIN_INJECT) private firebaseAdmin: FirebaseAdminSDK,
  ) {}

  getUsers() {
    return this.firebaseAdmin.auth().listUsers();
  }
}

Originally based on https://github.com/tfarras/nestjs-firebase-admin

About

NestJS Module for Firebase Admin SDK

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%