How to use the firebase.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 Lambda-School-Labs / CS9-KnowledgeRocket / server / auth / AuthRouter.js View on Github external
const mongoose = require('mongoose');

// Variable to Initialize Firebase Client App
let init_firebase;
// Variable to Initialize Firebase Admin App
const serviceAccount = {
    projectId: process.env.REACT_APP_FIRE_PROJECT_ID,
    clientEmail: process.env.SERVER_FIRE_CLIENT_EMAIL,
    privateKey: process.env.SERVER_FIRE_PRIVATE_KEY.replace(/\\n/g, '\n'),
};

// Init FireBase App if none exists
if (!Firebase.apps.length) {
    init_firebase = Firebase.initializeApp(FIREBASE_CONFIG);
} else {
    init_firebase = Firebase.apps[0];
}

// Initialize Firebase Admin App
admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    databaseURL: `${process.env.REACT_APP_FIRE_DB_URL}`,
});
router.route('/').post(post);
router.route('/:id').put(modifyUser);

function modifyUser(req, res) {
    const { id } = req.params;
    const password = req.body.changes.currentPW;
    const email = req.body.email;
    const newPW = req.body.changes.newPW;
    const ccEmail = req.body.changes.ccEmail;
github pubpub / pubpub-editor / src / addons / Collaborative / firebasePlugin.js View on Github external
};

		this.props = {
			decorations: this.decorations
		};

		this.onForksUpdate = onForksUpdate;
		this.onClientChange = onClientChange;
		this.onStatusChange = onStatusChange;
		this.localClientId = localClientId;
		this.localClientData = localClientData;
		this.editorKey = editorKey;
		this.selfChanges = {};
		this.startStepIndex = startStepIndex;

		const existingApp = firebase.apps.reduce((prev, curr)=> {
			if (curr.name === editorKey) { return curr; }
			return prev;
		}, undefined);

		if (!existingApp) {
			this.firebaseApp = firebase.initializeApp(firebaseConfig, editorKey);
		} else {
			this.firebaseApp = existingApp;
		}

		if (firebaseConfig) {
			this.rootRef = firebase.database(this.firebaseApp);
			this.rootRef.goOnline();
			this.firebaseRef = this.rootRef.ref(editorKey);
		// } else if (rootRef) {
		// 	this.rootRef = rootRef;
github Canner / canner-firebase-cms / schema / utils / index.js View on Github external
import firebase from 'firebase';
import {FirebaseClientStorage} from '@canner/storage';
import * as GraphQLinterface from 'canner-graphql-interface';

if (!firebase.apps.length) {
  // Setup connector to connect your services
  firebase.initializeApp({
    apiKey: "AIzaSyDU3UUHg9T2Bu-YqUaYAZIKETpLelLjhPk",
    authDomain: "fir-cms-15f83.firebaseapp.com",
    databaseURL: "https://fir-cms-15f83.firebaseio.com",
    projectId: "fir-cms-15f83",
    storageBucket: "fir-cms-15f83.appspot.com",
    messagingSenderId: "12548835933"
  });
}
const defaultApp = firebase.app();
const connector = new GraphQLinterface.FirebaseRtdbClientConnector({
  database: defaultApp.database()
});

const imageStorage = new FirebaseClientStorage({
github firebase / firebase-js-sdk / packages / testing / src / api / index.ts View on Github external
export function apps(): firebase.app.App[] {
  return firebase.apps;
}
github allenday / nanostream-dataflow / NanostreamDataflowMain / webapp / src / main / app-vue-js / src / views / Vis.vue View on Github external
firebaseInit: function () {
                if (!firebase.apps.length) {
                    console.log('Connect to DB with config:', this.config)
                    firebase.initializeApp(this.config);
                }

                const db = firebase.firestore();
                db.settings({
                    timestampsInSnapshots: true
                });
                console.log('== db init finished ==')
                return db;
            },
github MaartenDesnouck / google-apps-script / lib / functions / firebase.js View on Github external
async function authWithFirebase(auth) {
    try {
        const config = {
            apiKey: constants.FIREBASE_DATABASE_PUBLIC_APIKEY,
            databaseURL: constants.FIREBASE_DATABASE_URL,
        };

        if (!firebase.apps.length) {
            firebase.initializeApp(config);
        }

        const credential = firebase.auth.GoogleAuthProvider.credential(auth.credentials.id_token);
        await firebase.auth().signInWithCredential(credential);

        return true;
    } catch (err) {
        err.origin = 'authWithFirebase';
        await error.log(err);
        return false;
    }
}
github crabjs / crabjs-cms / core / core_route.js View on Github external
app.get('*', function (req, res, next) {
        let fs = require('fs'),
            path = require('path');

        var files = fs.readdirSync(__base + '/config/firebase');

        if (path.extname(files[0]) === '.json') {
            if (firebase.apps.length == 0) {
                firebase.initializeApp({
                    databaseURL: 'https://crab-cms.firebaseio.com',
                    serviceAccount: __base + '/config/firebase/' + files[0]
                });
            }
            if (req.user) {
                res.locals.fb_token = firebase.auth().createCustomToken(`${req.user._id}`);
            }
        }

        res.locals.user = req.user;
        next();
    });
github Canner / canner-firestore-cms / pages / login.js View on Github external
import * as React from 'react';
import * as firebase from 'firebase';
import {Row, Col, Form, Input, Icon, Button, Alert, notification} from 'antd';
import GithubCorner from 'react-github-corner';
import {LoginContainer, LogoContainer, FooterContainer, BodyWrapper} from '../components/app';
import firebaseConfig from '../config-firebase';

const FormItem = Form.Item;

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

class CMSApp extends React.Component {

  static async getInitialProps () {
    return {}
  }

  handleSubmit = (e) => {
    e.preventDefault();
    const {history} = this.props;
    this.props.form.validateFields((err, values) => {
      if (!err) {
        firebase.auth().signInWithEmailAndPassword(values.email, values.password)
          .then((result) => {
github Canner / canner-firebase-cms / pages / index.js View on Github external
import * as React from 'react';
import * as firebase from 'firebase';
import IndexPage from '../components/indexPage';
import firebaseConfig from '../config-firebase';

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

export default IndexPage;