Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Firebase Admin Module for Nest.js Framework

License

Notifications You must be signed in to change notification settings

REDREDGROUP/nestjs-firebase-admin

 
 

Repository files navigation

About this package

The original author of this repository is Aginix Technologies Co., Ltd.. The repertoire has been forked.

NPM Version Package License NPM Downloads

Description

Firebase Admin Module for Nest.js Framework

Installation

$ yarn add @redredgroup/nestjs-firebase-admin #yarn
$ npm i @redredgroup/nestjs-firebase-admin --save #npm

Import module

import { Module } from '@nestjs/common';
import { FirebaseAdminModule } from '@redredgroup/nestjs-firebase-admin';
import * as admin from 'firebase-admin';

@Module({
  imports: [
    FirebaseAdminModule.forRootAsync({
      useFactory: () => ({
        credential: admin.credential.applicationDefault(),
      }),
    }),
  ],
})
export class AppModule {}

//Or the forRootAsync module using @nestjs/Config

import { Module } from '@nestjs/common';
import { FirebaseAdminModule } from '@redredgroup/nestjs-firebase-admin';
import * as admin from 'firebase-admin';

@Module({
  imports: [
    FirebaseAdminModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        credential: admin.credential.cert({
          projectId: config.get('FB_PROJECT_ID'),
          clientEmail: config.get('FB_CLIENT_EMAIL'),
          privateKey: config.get('FB_PRIVATE_KEY'),
        }),
      }),
    }),
  ],
})
export class AppModule {}

Example

Inject Authentication Service

import { Injectable } from '@nestjs/common';
import { FirebaseAuthenticationService } from '@redredgroup/nestjs-firebase-admin';

@Injectable()
export class AppService {
  constructor(private firebaseAuth: FirebaseAuthenticationService) {}

  getUsers() {
    return this.firebaseAuth.listUsers();
  }
}

Compatibility Table

firebase-admin NestJS Library
10.xx master
10.xx 1.0.1
8.xx 1.xx

About

Firebase Admin Module for Nest.js Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%