npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@speakbox/nestjs-firebase-admin

v3.1.0

Published

NestJS Firebase Admin Service Factory

Downloads

23

Readme

Installation

npm install @speakbox/nestjs-firebase-admin

Usage

Import the module and the service in your NestJS application:

import { Module } from '@nestjs/common';
import { FirebaseModule, FirebaseService } from '@speakbox/nestjs-firebase-admin';

@Module({
  imports: [FirebaseModule],
  providers: [FirebaseService],
})
export class AppModule {}

Using the service

import { Inject, Injectable } from "@nestjs/common";
import { FirebaseService } from '@speakbox/nestjs-firebase-admin';

@Injectable()
export class ExampleService {
  constructor(
    @Inject(FirebaseService) private readonly firebase: FirebaseService,
  ) {}
  
  exampleAuth() {
    return this.firebase.auth.getUser('userId');
  }
  
  exampleFirestore() {
    return this.firebase.firestore.collection('users').get();
  }
  
  exampleStorage() {
    return this.firebase.storage.bucket('bucketName').file('fileName').download();
  }
}

For more information on how to use the service, please refer to the Firebase Admin SDK documentation or the NestJS Documentation.

Using the middleware

import { MiddlewareConsumer, Module } from '@nestjs/common';
import { SomeController } from './some.controller';
import { FirebaseModule, FirebaseService, FirebaseMiddleware } from '@speakbox/nestjs-firebase-admin';

@Module({
  imports: [FirebaseModule],
  controllers: [SomeController],
  providers: [FirebaseService, FirebaseMiddleware],
})
export class AppModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(FirebaseModule).forRoutes(SomeController);
  }
}

For more information on how to use middlewares, see the NestJS documentation.

Environment variables

This package relies on environment variables to configure the Firebase Admin SDK:

# Application environment
# If set to "development", it will assume the use of the Firebase emulators (please see emulator related environment variables below)
# If set to anything else, it will assume usage inside a Google Cloud environment and attempt to use applicationDefault() credentials
APP_ENV=production

# ONLY USE THE FOLLOWING IN DEVELOPMENT
# Firebase emulator
# Set this variable in your .env if you want to use the Firestore emulator
FIRESTORE_EMULATOR_HOST=localhost:7979

# Firebase Auth emulator
# Set this variable in your .env if you want to use the Firebase Auth emulator
FIREBASE_AUTH_EMULATOR_HOST=localhost:9099

# Firebase Storage emulator
# Set this variable in your .env if you want to use the Firebase Storage emulator
STORAGE_EMULATOR_HOST=localhost:9199

Change Log

See Changelog for more information.

Contributing

Contributions welcome! See Contributing.

Author

Valentin Prugnaud @valentinprgnd

License

Licensed under the MIT License - see the LICENSE file for details.