Skip to content

Instantly share code, notes, and snippets.

@corasan
Created August 13, 2020 21:55
Show Gist options
  • Select an option

  • Save corasan/330bfd5549dc25eaa694b8ea39fca960 to your computer and use it in GitHub Desktop.

Select an option

Save corasan/330bfd5549dc25eaa694b8ea39fca960 to your computer and use it in GitHub Desktop.
how to initialize Firebase Admin SDK depending if project is in Production project or Dev project
const functions = require('firebase-functions')
const admin = require('firebase-admin')
const config = JSON.parse(process.env.FIREBASE_CONFIG)
const isDev = config.projectId === 'dev-projectId'
const cert = isDev
? require('../dev-key.json')
: require('../prod-key.json')
config.credential = admin.credential.cert(cert)
admin.initializeApp(config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment