Reputation: 2962
I'm trying to implement Algolia
as explained: here.
There is a message that says: App ID and API Key are stored in functions config variables
const ALGOLIA_ID = functions.config().algolia.app_id;
const ALGOLIA_ADMIN_KEY = functions.config().algolia.api_key;
const ALGOLIA_SEARCH_KEY = functions.config().algolia.search_key;
I'm not familiar with Node.js at all. How should I create functions config variables
? It should be another file or another function or both?
Thanks!
Upvotes: 3
Views: 1905
Reputation: 1893
I get the feeling that the reasons the other answers may not be working for you is that you are looking for how to SET the config, as opposed to retrieving it.
If you don't have it already, you'll need to install the Firebase CLI, as per the steps in https://firebase.google.com/docs/cli/ .
with it installed, you can set up your config like so:
firebase functions:config:set algolia.app_id="YOUR_APP_ID_HERE"
You can set multiple variables at once by just separating them with spaces like so:
firebase functions:config:set algolia.api_id="YOUR_API_ID_HERE" algolia.search_key="YOUR_SEARCH_KEY_HERE"
To check you have the right config in there, you can also run:
firebase functions:config:get
Which should print out, in JSON format, the current config you have set.
Upvotes: 7
Reputation: 4908
The config variables are created using the firebase cli.
If you type firebase --help
you will get an output which includes the following:
functions:config:clone [options] clone environment config from another project
functions:config:get [path] fetch environment config stored at the given path
functions:config:set [values...] set environment config with key=value syntax
functions:config:unset [keys...] unset environment config at the specified path(s)
Upvotes: 1
Reputation: 5605
What are you trying to achieve exactly ?
I think you missed a step, this part uses the cloud function from firebase. You can see here "Extending Cloud Firestore with Cloud Functions" https://cloud.google.com/firestore/docs/extend-with-functions
Which will help you to extend firestore with cloud functions, and here you have a tutorial to write your first cloud function: https://firebase.google.com/docs/functions/get-started
Once you have that, you will notice that you will create
const functions = require('firebase-functions');
Which then allow you to do:
functions.config()
This is your "functions config variables". I'm guessing if you load Algolia dependency, you will have access to
functions.config().algolia.xxx;
Upvotes: 0