Socket
Book a DemoInstallSign in
Socket

@cuaklabs/nestjs-firebase-admin

Package Overview
Dependencies
Maintainers
6
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cuaklabs/nestjs-firebase-admin

meow meow meow

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
30
57.89%
Maintainers
6
Weekly downloads
 
Created
Source

Nest Logo

Nestjs Firebase Admin Module

Build status Coverage status

Description

Firebase Admin module for Nest.

Installation

$ npm i --save firebase-admin @cuaklabs/nestjs-firebase-admin

Quick Start

Initialization

import { FirebaseAdminModule } from '@cuaklabs/nestjs-firebase-admin';

@Module({
  imports: [FirebaseAdminModule.forRoot()],
})
export class AppModule {}
import { FirebaseAdminModule } from '@cuaklabs/nestjs-firebase-admin';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { AppOptions } from 'firebase-admin';

@Module({
  imports: [
    FirebaseAdminModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService): AppOptions => {
        return {
          databaseURL: configService.get('DATABASE_URL'),
        };
      },
    }),

  ],
})
export class AppModule {}

Inject Providers

import { Auth } from 'firebase-admin/auth';
import { CatService } from './CatService';
import { FirebaseAdminModule } from '@cuaklabs/nestjs-firebase-admin';

@Module({
  imports: [FirebaseAdminModule.injectProviders([Auth])],
  providers: [CatService],
})
export class CatModule {}
import { Auth } from 'firebase-admin/auth';
import { InjectFirebaseProvider } from '@cuaklabs/nestjs-firebase-admin';

export class CatService {
  constructor(@InjectFirebaseProvider(Auth) private readonly auth: Auth) {}

  public doSomething(): void {

  }
}

Multiple apps/connections

Initialization

import { FirebaseAdminModule } from '@cuaklabs/nestjs-firebase-admin';

@Module({
  imports: [FirebaseAdminModule.forRoot([{ name: 'app-name' }])],
})
export class AppModule {}
import { FirebaseAdminModule } from '@cuaklabs/nestjs-firebase-admin';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { AppOptions } from 'firebase-admin';

@Module({
  imports: [
    FirebaseAdminModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService): AppOptions => {
        return [
          { 
            name: 'app-name',
            appOptions: {
              databaseURL: configService.get('DATABASE_URL'),
            },
          },
        ];
      },
    }),

  ],
})
export class AppModule {}

Inject Providers

import { Auth } from 'firebase-admin/auth';
import { CatService } from './CatService';
import { FirebaseAdminModule } from '@cuaklabs/nestjs-firebase-admin';

@Module({
  imports: [FirebaseAdminModule.injectProviders([Auth], 'app-name')],
  providers: [CatService],
})
export class CatModule {}
import { Auth } from 'firebase-admin/auth';
import { InjectFirebaseProvider } from '@cuaklabs/nestjs-firebase-admin';

export class CatService {
  constructor(@InjectFirebaseProvider(Auth, 'app-name') private readonly auth: Auth) {}

  public doSomething(): void {

  }
}

Keywords

nestjs

FAQs

Package last updated on 11 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.