npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

iopa-db-firebase

1.4.9 • Public • Published

IOPA
iopa-db-firebase

NPM NPM NPM

NPM

About

This repository contains helper middleware functions for reading and writing to firebase

Using

npm install iopa-db-firebase --save

Server

var DBMiddleware = require('iopa-db-firebase');
 
// SET THE FOLLOWING IN ENVIRONMENT VARIABLES INSTEAD!
process.env.FIREBASE_CLIENT_EMAIL = "xxxx@xxxx-xxx.iam.gserviceaccount.com";
process.env.FIREBASE_PRIVATE_KEY = "-----BEGIN PR...";
process.env.FIREBASE_DATABASE_URL = "https://xxxxx-xxxx.firebaseio.com";
process.env.FIREBASE_ROOT = "/";
 
// Use the DBMiddleWare adds a .db object to every context record for remainder of chain
app.use(require(DBMiddleware));
app.use(require(DBMiddleware.filestorage));  // optional
function(context, next){
 
    context.db.put("/demo/item", {
        id: "1234",
        name: "demo"
    });
 
    context.db.get("/demo/item")
    .then(function(item){
            context.log(item.timestamp);
    });
 
    context.db.put("/demo/item", null);
 
    context.db.subscribe("/demo")
    .on("value", function(item){
         context.log(item.key);
    });
 
}

Browser

var DBMiddleware = require('iopa-db-firebase');
 
// SET THE FOLLOWING IN ENVIRONMENT VARIABLES INSTEAD!
  process.env.BROWSER = true
  process.env.FIREBASE_API_KEY" = "THISISMYPRIVATETOKEN"
  process.env.FIREBASE_AUTH_DOMAIN" = "xxxxxx.firebaseapp.com"
  process.env.FIREBASE_DATABASE_URL" ="https://xxxxx.firebaseio.com"
  process.env.FIREBASE_STORAGE_BUCKET" = "xxxxx.appspot.com"
  process.env.FIREBASE_MESSAGING_SENDER_ID = "nnnnnnnnnn"
  process.env.FIREBASE_ROOT": "/"
 
 
// Use the DBMiddleWare adds a .db object to every context record for remainder of chain
app.use(require(DBMiddleware));
function(context, next){
 
    context.db.put("/demo/item", {
        id: "1234",
        name: "demo"
    });
 
    context.db.get("/demo/item")
    .then(function(item){
            context.log(item.timestamp);
    });
 
    context.db.put("/demo/item", null);
 
    context.db.subscribe("/demo", function(item){
         context.log(item.key);
    });
 
}

License

Apache-2.0

API Reference Specification

IOPA

install

npm i iopa-db-firebase

Downloadsweekly downloads

0

version

1.4.9

license

Apache-2.0

homepage

iopa.io

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability