experimenting with getting credentials as needed instead of setting them at node-creation
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-firebase-admin",
|
"name": "node-red-contrib-firebase-admin",
|
||||||
"version": "1.1.19",
|
"version": "1.1.20",
|
||||||
"description": "A node-red module that wraps the server-side admin SDK of firebase, firestore, et.c.",
|
"description": "A node-red module that wraps the server-side admin SDK of firebase, firestore, et.c.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -10,8 +10,7 @@ module.exports = function(RED) {
|
|||||||
if(config.cred){
|
if(config.cred){
|
||||||
let c = RED.nodes.getNode(config.cred)
|
let c = RED.nodes.getNode(config.cred)
|
||||||
this.admin = c.admin
|
this.admin = c.admin
|
||||||
let global = this.context().global
|
this.config = c;
|
||||||
this.storage = c.storage || global.get('cloud-storage')
|
|
||||||
this.bucket = config.bucket || c.bucket
|
this.bucket = config.bucket || c.bucket
|
||||||
this.path = config.path
|
this.path = config.path
|
||||||
}
|
}
|
||||||
@ -20,6 +19,8 @@ module.exports = function(RED) {
|
|||||||
//console.log('configuring storage-list to listen for messages')
|
//console.log('configuring storage-list to listen for messages')
|
||||||
node.on('input', function(msg) {
|
node.on('input', function(msg) {
|
||||||
if(msg && msg.payload){
|
if(msg && msg.payload){
|
||||||
|
let global = this.context().global
|
||||||
|
this.storage = this.config.storage || global.get('cloud-storage')
|
||||||
let path = msg.payload.path || this.path
|
let path = msg.payload.path || this.path
|
||||||
let bucket = msg.payload.bucket || this.bucket
|
let bucket = msg.payload.bucket || this.bucket
|
||||||
console.log('storage-list listing files from bucket "'+bucket+'" path "'+path+'"')
|
console.log('storage-list listing files from bucket "'+bucket+'" path "'+path+'"')
|
||||||
|
|||||||
@ -9,6 +9,7 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
if(config.cred){
|
if(config.cred){
|
||||||
let c = RED.nodes.getNode(config.cred)
|
let c = RED.nodes.getNode(config.cred)
|
||||||
|
this.config = c;
|
||||||
this.admin = c.admin
|
this.admin = c.admin
|
||||||
let global = this.context().global
|
let global = this.context().global
|
||||||
this.storage = c.storage || global.get('cloud-storage')
|
this.storage = c.storage || global.get('cloud-storage')
|
||||||
@ -18,15 +19,16 @@ module.exports = function(RED) {
|
|||||||
console.log('config is '+config)
|
console.log('config is '+config)
|
||||||
}
|
}
|
||||||
|
|
||||||
let global = this.context().global
|
|
||||||
this.storage = global.get('cloud-storage')
|
|
||||||
console.log('* storage-read set this.storage to '+this.storage)
|
|
||||||
|
|
||||||
//console.log('configuring storage-read to listen for messages')
|
//console.log('configuring storage-read to listen for messages')
|
||||||
node.on('input', function(msg) {
|
node.on('input', function(msg) {
|
||||||
if(msg && msg.payload){
|
if(msg && msg.payload){
|
||||||
let path = msg.payload.path || msg.path || this.path
|
let path = msg.payload.path || msg.path || this.path
|
||||||
let bucket = msg.payload.bucket || msg.bucket || this.bucket
|
let bucket = msg.payload.bucket || msg.bucket || this.bucket
|
||||||
|
let global = this.context().global
|
||||||
|
this.storage = global.get('cloud-storage')
|
||||||
|
console.log('* storage-read set this.storage to '+this.storage)
|
||||||
console.log('------------------------------ storage-read reading from bucket "'+bucket+'" path "'+path+'" this.storage = '+this.storage)
|
console.log('------------------------------ storage-read reading from bucket "'+bucket+'" path "'+path+'" this.storage = '+this.storage)
|
||||||
if(msg.payload.files && msg.payload.files.length > 0){
|
if(msg.payload.files && msg.payload.files.length > 0){
|
||||||
console.log('--reading from files')
|
console.log('--reading from files')
|
||||||
|
|||||||
@ -7,10 +7,10 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
|
|
||||||
if(config.cred){
|
if(config.cred){
|
||||||
let c = RED.nodes.getNode(config.cred)
|
let c = RED.nodes.getNode(config.cred);
|
||||||
|
this.config = c;
|
||||||
this.admin = c.admin
|
this.admin = c.admin
|
||||||
let global = this.context().global
|
|
||||||
this.storage = c.storage || global.get('cloud-storage')
|
|
||||||
this.bucket = config.bucket || c.bucket
|
this.bucket = config.bucket || c.bucket
|
||||||
this.path = config.path
|
this.path = config.path
|
||||||
/*
|
/*
|
||||||
@ -24,6 +24,8 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
node.on('input', function(msg) {
|
node.on('input', function(msg) {
|
||||||
if(msg && msg.payload){
|
if(msg && msg.payload){
|
||||||
|
let global = this.context().global
|
||||||
|
this.storage = this.config.storage || global.get('cloud-storage')
|
||||||
let path = msg.payload.path || msg.path|| this.path
|
let path = msg.payload.path || msg.path|| this.path
|
||||||
let bucket = msg.payload.bucket || msg.bucket || this.bucket
|
let bucket = msg.payload.bucket || msg.bucket || this.bucket
|
||||||
let contents = msg.payload.contents || msg.payload
|
let contents = msg.payload.contents || msg.payload
|
||||||
|
|||||||
Reference in New Issue
Block a user