How to use the firebase/app.apps function in firebase

To help you get started, we’ve selected a few firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pubpub / pubpub / client / utils / firebaseClient.js View on Github external
export const initFirebase = (rootKey, authToken) => {
	const firebaseAppName = `App-${rootKey}`;
	/* Check if we've already initialized an Firebase App with the */
	/* same name in this local environment */
	const existingApp = firebase.apps.reduce((prev, curr) => {
		return curr.name === firebaseAppName ? curr : prev;
	}, undefined);

	/* Use the existing Firebase App or initialize a new one */
	const firebaseApp = existingApp || firebase.initializeApp(getFirebaseConfig(), firebaseAppName);
	const database = firebase.database(firebaseApp);

	/* Authenticate with the server-generated token */
	return firebase
		.auth(firebaseApp)
		.signInWithCustomToken(authToken)
		.then(() => {
			return [database.ref(`${rootKey}`), database.ref('.info/connected')];
		})
		.catch((err) => {
			console.error('Error authenticating firebase', err);
github celo-org / celo-monorepo / packages / web / server / FirebaseClient.ts View on Github external
async function getFirebase() {
  if (!firebase.apps.length) {
    const { publicRuntimeConfig } = getConfig()
    // These variables are defined in `env-config.js` file in the parent directory.
    firebase.initializeApp(publicRuntimeConfig.FIREBASE_CONFIG)
  }
  return firebase
}
github carbon-app / carbon / lib / client.js View on Github external
return firebase
    .auth()
    .setPersistence(firebase.auth.Auth.Persistence.LOCAL)
    .then(() => firebase.auth().signInWithPopup(provider))
    .catch(console.error)
}

export function loginGitHub() {
  const provider = new firebase.auth.GithubAuthProvider()
  provider.setCustomParameters({
    allow_signup: 'true'
  })
  return login(provider)
}

export default firebase.apps.length ? firebase : null
github potato4d / nuxt-firebase-sns-example / app / plugins / firebase.js View on Github external
import firebase from 'firebase/app'
import 'firebase/firestore'
import 'firebase/auth'

if (!firebase.apps.length) {
  firebase.initializeApp({
    apiKey: process.env.APIKEY,
    authDomain: process.env.AUTHDOMAIN,
    databaseURL: process.env.DATABASEURL,
    projectId: process.env.PROJECTID,
    storageBucket: process.env.STORAGEBUCKET,
    messagingSenderId: process.env.MESSAGINGSENDERID,
    appId: process.env.APPID
  })
}

export default (context, inject) => {
  inject('firebase', firebase)
  inject('firestore', firebase.firestore())
  inject('auth', firebase.auth())
}
github Eckhardt-D / nuxt-fire-auth / services / firebase.js View on Github external
import firebase from "firebase/app";
import "firebase/auth";

const config = {
  apiKey: process.env.NUXT_ENV_API_KEY,
  authDomain: process.env.NUXT_ENV_AUTH_DOMAIN,
  databaseURL: process.env.NUXT_ENV_DATABASE_URL,
  projectId: process.env.NUXT_ENV_PROJECT_ID,
  storageBucket: process.env.NUXT_ENV_STORAGE_BUCKET,
  messagingSenderId: process.env.NUXT_ENV_MESSAGE_SENDER_ID,
  appId: process.env.NUXT_ENV_APP_ID
};

!firebase.apps.length ? firebase.initializeApp(config) : "";

export const auth = firebase.auth();
github neo4j / neo4j-browser / src / shared / services / browserSyncService.js View on Github external
const appIsInitialized = () => firebase.apps.length && firebase.apps.length > 0
github oddbit / tanam / src / theme / plugins / firebase.js View on Github external
import firebase from 'firebase/app';
import 'firebase/firestore';

const config = {
  apiKey: 'AIzaSyD-sz6tSPCKKhQBJnl1SuAzrnMktnMOFSI',
  authDomain: 'tanam-dev.firebaseapp.com',
  databaseURL: 'https://tanam-dev.firebaseio.com',
  projectId: 'tanam-dev',
  storageBucket: 'tanam-dev.appspot.com',
  messagingSenderId: '2622678578'
};

const firebaseApp = !firebase.apps.length
  ? firebase.initializeApp(config)
  : firebase.app();

const firestore = firebaseApp.firestore();
firestore.settings({ timestampsInSnapshots: true });

export { firestore };
github webcore-it / nuxt2-ssr-on-firebase / src / plugins / firebase.js View on Github external
export default () => {
  if (!firebase.apps.length) {
    firebase.initializeApp(process.env.firebaseConfig);
  }

  const firestore = firebase.firestore();
  const settings = {};
  firestore.settings(settings);
}
github DavidViaene / react-firebase-renderprops / src / Firebase.js View on Github external
render() {
    const { render, config } = this.props;

    const firebaseApp = firebase.apps.length
      ? firebase.apps[0]
      : firebase.initializeApp(config);

    return render(firebaseApp);
  }
}
github orange-alliance / TOA-DataSync / src / assets / js / firebase.js View on Github external
const firebase = require("firebase/app");
require("firebase/auth");
const firebaseConfig = require('../../env/env.firebase');

if (firebase.apps.length === 0) {
  firebase.initializeApp(firebaseConfig);
}

module.exports = { firebase };