nestjs-firebase-admin icon indicating copy to clipboard operation
nestjs-firebase-admin copied to clipboard

Curious about how this compares to my current implementation

Open dilizarov opened this issue 5 years ago • 0 comments

I've incorporated Firebase Auth into my NestJS product. It requires firebase-admin and I include like such:

main.ts

import { NestFactory } from "@nestjs/core";
import { AppModule } from "app.module";
import * as admin from "firebase-admin";

/**
 * If there comes a time that we want to exclude "api" prefix
 * from certain controllers, then refernce this answer:
 *
 * https://github.com/nestjs/nest/issues/255#issuecomment-360749246
 *
 * Otherwise, this functionality doesn't exist atm.
 * I think it is actively being discussed/worked on though
 */
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.setGlobalPrefix("api");

  // Redacted the URL and credential for our purposes here
  admin.initializeApp({
    credential: <CREDENTIAL_CERT>,
    databaseURL: <DATEBASE_URL>
  });

  await app.listen(5000);
}
bootstrap();

Everything works fine, but then I came across this npm library.

Is there a benefit to using your method over what I did above? Is your method explicitly for baking firebase-admin into the dependency injection flow?

dilizarov avatar Sep 08 '20 00:09 dilizarov