Firebase details need to be set in your .env
, including a reference to a .json
file with the service account credentials and the URL for the firebase DB.
Modules that want to access firebase should require('../firebase.js')
. Example:
var firebase = require('../firebase.js');
...
firebase(function(db) {
var threadReference = db.ref(threadID);
var moduleReference = threadReference.child('/moduleName');
var resourceReference = moduleReference.child('/resource');
resourceReference.once('value', function(snapshot) {
console.log(snapshot.val());
});
resourceReference.update({
key: 'value'
});
}
All interactions with the database should be done by /threadID/moduleName/
, and modules should generally only access their given thread ID/module name namespace.