Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the test suite to use firebase-admin #93

Merged
merged 6 commits into from
Nov 23, 2016
Merged

Conversation

cbraynor
Copy link
Contributor

Fixes #90

NPM (at least v3.10.8) seems to install optional dependencies by default which is not what we want I don't think. I think it's clear from the documentation that you always have to install firebase-queue alongside either firebase-admin or firebase, so let's just remove it from anything other than the devDependencies.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0004%) to 99.803% when pulling fd3078c on firebase-admin into 06646e0 on master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 23, 2016

Coverage Status

Coverage decreased (-0.0004%) to 99.803% when pulling fd3078c on firebase-admin into 06646e0 on master.

Copy link

@jwngr jwngr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a few docs suggestions, but the code changes looked good - and fairly minimal, which is great! The only other thing I think may be worth mentioning in the docs is that if developers are running the queue on GCP infrastructure, users can make use of admin.credential.applicationDefault() and won't even need to bring their own service account.

@@ -44,6 +44,8 @@ queue

See [Custom references to tasks and specs](#custom-references-to-tasks-and-specs) for defining the locations of these other than the default.

Firebase Queue works with a Firebase database reference from either the [firebase-admin](https://www.npmjs.com/package/firebase-admin) (for admin access) or [firebase](https://www.npmjs.com/package/firebase) (for end-user access) NPM module, though it is mainly intended to perform administrative actions. Check out [this blog post](https://firebase.googleblog.com/2016/11/bringing-firebase-to-your-server.html) for an introduction to firebase-admin.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • s/database/Database/ (that's the official way we write it in our docs)
  • Put backticks around firebase-admin (two instances) and firebase (one instance)
  • s/NPM/npm (official name is lowercase)

firebase.initializeApp({
serviceAccount: 'path/to/serviceAccountCredentials.json',
admin.initializeApp({
credential: admin.credential.cert('path/to/serviceAccountCredentials.json'),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People have been tripped up by the fact that the link here is relative to where the script is run. I've updated the official docs to make this more foolproof:

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

firebase.initializeApp({
serviceAccount: 'path/to/serviceAccountCredentials.json',
admin.initializeApp({
credential: admin.credential.cert('path/to/serviceAccountCredentials.json'),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on the above.

firebase.initializeApp({
serviceAccount: 'path/to/serviceAccountCredentials.json',
admin.initializeApp({
credential: admin.credential.cert('path/to/serviceAccountCredentials.json'),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on the above.

@jwngr jwngr assigned cbraynor and unassigned jwngr Nov 23, 2016
@cbraynor
Copy link
Contributor Author

Application default credentials are mentioned in the blog post linked. These docs are mainly for the initial development of a queue where you're unlikely to have such credentials installed.

@cbraynor cbraynor assigned jwngr and unassigned cbraynor Nov 23, 2016
@coveralls
Copy link

coveralls commented Nov 23, 2016

Coverage Status

Coverage decreased (-0.0004%) to 99.803% when pulling 4eafd55 on firebase-admin into 06646e0 on master.

Copy link

@jwngr jwngr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (with one minor nit that you can fix if you'd like).


```js
// my_queue_worker.js

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

var serviceAccount = require('path/to/serviceAccountCredentials.json')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missing semicolon (same with the two other places you have this).

@jwngr jwngr assigned cbraynor and unassigned jwngr Nov 23, 2016
@coveralls
Copy link

coveralls commented Nov 23, 2016

Coverage Status

Coverage decreased (-0.0004%) to 99.803% when pulling 6cfdf59 on firebase-admin into 06646e0 on master.

@cbraynor cbraynor merged commit 16217dc into master Nov 23, 2016
@cbraynor cbraynor deleted the firebase-admin branch November 23, 2016 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants