Day 16: Firebase and Twilio

Tuesday, June 21, 2016

Topics

Firebase 3.0 & AngularFire 2.0

  • $firebaseArray for creating an array-like object that syncs with Firebase
  • $add
  • $remove
  • $save

Firebase 3.0 app initialization for front-end

var config = {
  apiKey: '<your-api-key>',
  authDomain: '<your-auth-domain>',
  databaseURL: '<your-database-url>',
  storageBucket: '<your-storage-bucket>'
};
firebase.initializeApp(config);

Firebase 3.0 app initialization for Node.js

var firebase = require("firebase");
firebase.initializeApp({
  serviceAccount: "path/to/serviceAccountCredentials.json",
  databaseURL: "https://databaseName.firebaseio.com"
});

dotenv

  • Loads environment variables from .env for nodejs projects
  • Should I commit my .env file? Answer here

Twilio

  • Cloud-based communication for text and phone calls
  • Supports multiple server-side SDKs, including Java, C#, Node, Ruby, and Python

Node setup

var twilio = require('twilio');
var client = new twilio.RestClient(accountSid, authToken);

client.messages.create({
    body: 'Hello from Node',
    to: '+12345678901',  // Text this number
    from: '+12345678901' // From a valid Twilio number
}, function(err, message) {
    if(err) {
        console.error(err.message);
    }
});

Project

  • Mutant Office Hours (Angular): source
  • Mutant Office Hours Server (Node): source