Integrate remote config with Nodejs
Asked Answered
P

2

5

I'm looking for a better way to integrate firebase remote config into my Nodejs server.

Basically I have 2 questions,

  1. 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?

  2. 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.

Prieto answered 22/4, 2020 at 11:52 Comment(1)
Now you can fetch config on servers normally firebase.google.com/docs/remote-config/serverTyrannicide
S
8

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.

Superiority answered 22/4, 2020 at 14:5 Comment(0)
E
11

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

Encyclopedic answered 30/9, 2020 at 11:55 Comment(3)
The link is broken.Norman
updated firebase.google.com/docs/reference/admin/node/…Encyclopedic
This should be changed to the correct answerLeandraleandre
S
8

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.

Superiority answered 22/4, 2020 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.