Last active
April 21, 2021 13:44
-
-
Save elliotlarson/8e16160c93d58f10646be006243441e7 to your computer and use it in GitHub Desktop.
Simple Node.js Firebase repl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Using the firebase-admin approach where database security rules do not apply. | |
// Here you are authenticating with a private key. The key JSON file is available via | |
// the Firebase web UI: project settings > service accounts > generate new private key. | |
var admin = require("firebase-admin"); | |
admin.initializeApp({ | |
credential: admin.credential.cert(".adminServiceAccountKey.json"), | |
databaseURL: "https://databaseName.firebaseio.com" | |
}); | |
var database = admin.database(); | |
var repl = require("repl"); | |
var replServer = repl.start({ | |
prompt: "firebase> ", | |
}); | |
replServer.context.admin = admin; | |
replServer.context.database = database; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Using the firebase approach where you are subject to database security rules. | |
var firebase = require('firebase') | |
var config = { | |
apiKey: "apiKey", | |
authDomain: "projectId.firebaseapp.com", | |
databaseURL: "https://databaseName.firebaseio.com", | |
storageBucket: "bucket.appspot.com" | |
} | |
firebase.initializeApp(config); | |
var database = firebase.database(); | |
var repl = require("repl"); | |
var replServer = repl.start({ | |
prompt: "firebase> ", | |
}); | |
replServer.context.firebase = firebase; | |
replServer.context.database = database; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment