Created
August 13, 2020 21:55
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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