From e29eec83f8fb76a1b547e8286ffca4e450845f12 Mon Sep 17 00:00:00 2001 From: Peter Svensson Date: Sat, 20 Jul 2019 17:07:12 +0200 Subject: [PATCH] added guard for firebase-config init call without creentials set --- firebase-config.js | 17 ++++++++++------- package.json | 2 +- storage/storage-write.js | 8 +++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/firebase-config.js b/firebase-config.js index 81282ea..2fd5fb6 100644 --- a/firebase-config.js +++ b/firebase-config.js @@ -31,13 +31,16 @@ module.exports = function(RED) { }); global.set('firebase', _admin) } - console.log('********************************************************** setting storage....') - s = new Storage({ - //projectId: 'something-2e584', - //email: 'firebase-adminsdk-d1xiy@something-2e584.iam.gserviceaccount.com', - credentials: this.credentials - }) - global.set('cloud-storage', s) + if(this.credentials){ + //console.log('********************************************************** setting storage.... credentials are') + //console.dir(this.credentials) + s = new Storage({ + projectId: this.credentials.project_id, + //email: 'firebase-adminsdk-d1xiy@something-2e584.iam.gserviceaccount.com', + credentials: this.credentials + }) + global.set('cloud-storage', s) + } //s = new Storage() diff --git a/package.json b/package.json index 8944fde..7de731e 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ } }, "dependencies": { - "@google-cloud/storage": "^3.0.2", + "@google-cloud/storage": "^3.0.3", "@node-red/runtime": "^0.20.6", "firebase-admin": "^8.0.0" } diff --git a/storage/storage-write.js b/storage/storage-write.js index 5ac4fc3..e43fc4b 100644 --- a/storage/storage-write.js +++ b/storage/storage-write.js @@ -12,9 +12,15 @@ module.exports = function(RED) { this.storage = c.storage this.bucket = config.bucket || c.bucket this.path = config.path + /* + console.log('configuring storage-write to listen for messages. config is') + console.dir(config) + console.log('storage is') + console.dir(this.storage) + */ } - //console.log('configuring storage-write to listen for messages') + node.on('input', function(msg) { if(msg && msg.payload){ let path = msg.payload.path || msg.path|| this.path