FirebaseExtended / firebase-queue

MIT License
787 stars 108 forks source link

Update dependency to the Firebase Admin Node.js #90

Closed jwngr closed 7 years ago

jwngr commented 7 years ago

Now that the Firebase Admin Node.js SDK is available, we should switch the dependency for Firebase Queue from firebase to firebase-admin.

jwngr commented 7 years ago

Note that you can use the new Admin Node.js SDK with Firebase Queue today, even before we switch out the underlying dependency. Instead of:

// my_queue_worker.js

var Queue = require('firebase-queue');
var firebase = require('firebase');

firebase.initializeApp({
  serviceAccount: 'path/to/serviceAccountCredentials.json',
  databaseURL: '<your-database-url>'
});

var ref = firebase.database().ref('queue');
var queue = new Queue(ref, function(data, progress, resolve, reject) {
  // ...
});

You would do:

// my_queue_worker.js

var Queue = require('firebase-queue');
var admin = require('firebase-admin'); // CHANGED

admin.initializeApp({ // CHANGED
  credential: admin.credential.cert('path/to/serviceAccountCredentials.json'), // CHANGED
  databaseURL: '<your-database-url>'
});

var ref = admin.database().ref('queue'); // CHANGED
var queue = new Queue(ref, function(data, progress, resolve, reject) {
  // ...
});
jwngr commented 7 years ago

After talking with @drtriumph, our plan is to do the following:

  1. Remove the straight dependency on firebase by using the sentinel value ({".sv": "timestamp"}) instead of firebase.database.ServerValue.TIMESTAMP.
  2. List firebase and firebase-admin in optionalDepenencies instead of peerDependencies. That way, people can use Firebase Queue with either the firebase or firebase-admin module and it is not a breaking change for existing users.
kirtan403 commented 7 years ago

I recently developed a firebase queue backend which is yet to go on a production and though I am stuck! Thanks 😄