Firebase Admin Multi App Initialization

require('firebase');
var admin = require('firebase-admin');
var firstServiceAccount = require('path/to/service-account-1');
var secondServiceAccount = require('path/to/service-account-2');

var _first = admin.initializeApp(
  {
    credential: admin.credential.cert(firstServiceAccount),
    databaseURL: 'https://<1st-db-name>.firebaseio.com'
  }, 
  'first' // this name will be used to retrieve firebase instance. E.g. first.database();
);

var _second = admin.initializeApp(
  {
    credential: admin.credential.cert(secondServiceAccount),
    databaseURL: 'https://<2nd-db-name>.firebaseio.com'
  }, 
  'second' // this name will be used to retrieve firebase instance. E.g. second.database();
);

exports.first = _first;
exports.second = _second;

Usage

var first = require('../path/to/the/file/above');
var second = require('../path/to/the/file/above');
 
first.database();
second.database();

References
https://gist.github.com/jofftiquez/1317de9ce97ab72b8295013a3f2ccff0
https://gist.github.com/jofftiquez/6d4bb432c7b25fe9a89e8f5231ea8ce2