@remi_grumeau

Mobile web & digital signage developer

Firebase

Realtime platform for application

Datas
Store datas & sync between clients
Hosting
Static files on HTTPS
(via Git)
Authentification
Tokens, sessions, rights, ...

Datas

Object reference as a data

Your database is an object
(equal to null by default)

Object reference as a data

can be equal to anything...

Object reference as a data

and of course, a set of objets

Object reference as a data

with each childnode being its own object reference

Object oriented API




var myAppRef = new Firebase('https://myapp.firebaseio.com');
var usersRef = new Firebase('https://myapp.firebaseio.com/users');

Connecting to your online database reference
in 2 lines of code

Object oriented API


var myAppRef = new Firebase('https://myapp.firebaseio.com');

myAppRef.set({'talks':['Firebase','RequireJS']}, onComplete);
myAppRef.set({'drinks':'coffee'}, onComplete);

JSON syntax

Object oriented API


var myAppRef = new Firebase('https://myapp.firebaseio.com');
myAppRef.on('value', function(dataSnapshot) {
  // when object reference receive a structur modification
});

myAppRef.on('child_added', function(childSnapshot, prevChildName) {
  // when the object reference received a "set" event
});

myAppRef.on('child_changed', function(childSnapshot, prevChildName) {
  // when the object reference received a "update" event
});

myAppRef.off('child_changed'); // stop listener

100% listeners & callbacks oriented

Object reference as a data

And four methods for writing data

Demo :)

bit.ly / emychat

Token JWTs


	// Generate a new secure JWT
var FirebaseTokenGenerator = require("./firebase-token-generator-node.js");
var tokenGenerator = new FirebaseTokenGenerator(YOUR_FIREBASE_SECRET);
var token = tokenGenerator.createToken({"app_user_id": 1234, "isModerator": true });
	

server to server talks

Rules


{
  "rules": {
    ".read": true,
    ".write": false
  }
}
Full access

Rules


{
  "rules": {
    ".read": true,
    "speaker": {
    	".write": false,
  	},
    }
  }
}
write only for this talk

Rules


{
  "rules": {
    "users": {
      "$user": {
        ".read": "$user == auth.username",
        ".write": "$user == auth.username"
      }
    }
  }
}
Access retricted to users own datas

auth()


var myAppRef = new Firebase('https://devfest15.firebaseio.com');
//Log me in
myAppRef.auth(AUTH_TOKEN, function(error, result) {
  if(error) {
    console.log("Login Failed!", error);
  } else {
    console.log('Authenticated successfully with payload:', result.auth);
    console.log('Auth expires at:', new Date(result.expires * 1000));
  }
});
	
Get auth token

Hosting

Angular example





  var myApp = angular.module("MyApp", ["firebase"]);

  function MyController($scope, $firebase) {
    var usersRef = new Firebase("https://myapp.firebaseio.com/users");
    // Automatically syncs everywhere in realtime
    $scope.people = $firebase(usersRef);
  }

Open Data Sets

Airport delay / CryotoCurrencies (BitCoin, LiteCoin, ...) / Earthquake / Transit (USA) / Weather (USA) / Parking (SanFan) / ...

> Open Data Sets

Any questions ?

Thanks a lot!