Integrate remote config with Nodejs
I'm looking for a better way to integrate firebase remote config into my Nodejs server.
Basically I have 2 questions,
firebase's Official js sdk documentation says remoteconfig does not support nodeJs, I was wondering what's the reason behind supporting web and not nodeJS?
nodejs-quickstart uses rest endpoint, if I use this technique for managing my server's config,would I have to Implement polling? or is there a better way?
PS : Env variables are not an option because these configs changed over the time.
Solution 1:
firebaser here
The REST API for Firebase Remote Config allows you to change/manage the configurations, it does not allow you to consume them.
In other words: the REST API allows you to code your own replacement for the Remote Config panel in the Firebase console, it does not allow you to code your own replacement for the client-side SDKs.
If you'd like to see the Remote Config consumer APIs also be ported to the Node.js SDK, I recommend that you file a feature request. I don't see this request very often though, so you might want to look for alternatives in the meantime.
Solution 2:
You can use admin SDK
const admin = require("firebase-admin");
const serviceAccount = require("path/toyour/firebase-adminsdk.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://<project-database>.firebaseio.com"
});
const getConfig = async () => {
let config = admin.remoteConfig();
const template = await config.getTemplate()
//all parameters will be under template.parameters
}
see docs here