Skip to content

Instantly share code, notes, and snippets.

@mattbajorek
Last active October 26, 2022 19:53
Show Gist options
  • Save mattbajorek/50a2b427484a80b24984a592eef9c0a1 to your computer and use it in GitHub Desktop.
Save mattbajorek/50a2b427484a80b24984a592eef9c0a1 to your computer and use it in GitHub Desktop.
Initializing firebase
import { Injectable } from '@nestjs/common';
import * as firebase from 'firebase-admin';
@Injectable()
export class NotificationsService {
constructor() {
// For simplicity these credentials are just stored in the environment
// However these should be stored in a key management system
const firebaseCredentials = JSON.parse(process.env.FIREBASE_CREDENTIAL_JSON);
firebase.initializeApp({
credential: firebase.credential.cert(firebaseCredentials),
databaseURL: process.env.FIREBASE_DATABASE_URL,
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment