コード例 #1
0
    function FirebaseStore(options, fn) {
        options = options || {};
        Store.call(this, options);

        this.host = options.host;
        this.token = options.token;
        this.serviceAccount = options.serviceAccount;
        this.cleanSid = options.cleanSid || function (sid) {
            // firebase does not allow certain characters
            //  see: https://www.firebase.com/docs/creating-references.html
            return sid.replace(/\.|#|\$|\[|\]/g, '_');
        };

        if (this.token) {
            debugger;
            firebase.initializeApp({
                serviceAccount: this.serviceAccount,
                databaseUrl: 'https://' + this.host
            });
            debugger;
            var sessionRef = firebase.database.ref();
            debugger;
            sessionRef.authWithCustomToken(this.token, function(err){
                if(err){
                    fn(err);
                }
            });
        }

        this.reapInterval = options.reapInterval || (oneDayInMilliseconds / 4);
        if (this.reapInterval > 0) {
            setInterval(this.reap.bind(this), this.reapInterval);
        }

    }
コード例 #2
0
ファイル: server.js プロジェクト: andrewcupper/substation33
const express     = require('express');
const bodyParser  = require('body-parser');
const firebase    = require('firebase');
const app         = express();
const router      = express.Router();
const port        = 8081;

const helpers     = require('./server/helpers.js');

firebase.initializeApp({
    "databaseURL": "https://project-6353258358688553392.firebaseio.com",
    "serviceAccount": "config/firebase.json"
});

firebase.database.enableLogging(true);

var db = firebase.database();
var ref = db.ref("collections");

app.use(express.static(__dirname + '/build'));
app.use('/api', router);

router.use(bodyParser.json());

router.route('/collection')
  .post((req, res) => {
    
    var newCollectionKey = firebase.database().ref().child('collections').push().key;

    var updates = {};