Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fetch firebase remote config - a script for npm build
require('dotenv').config()
const admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.cert(
process.env.NODE_ENV === 'production'
? require('./gcp.json')
: JSON.parse(process.env.FIREBASE_ADMIN_SDK)
),
databaseURL: process.env.FIREBASE_DATABASE_URL
});
admin.remoteConfig().getTemplate()
.then(content =>
require('fs').writeFile('remoteConfig.json', JSON.stringify(content.parameterGroups), 'utf8',
(err) => err
? console.error(`failed to write remote conf: ${err}`)
: process.exit()
))
.catch(err => console.error(`failed fetching remote conf: ${err}`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment