How to use the firebase/app.app 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 CharlBest / nean-stack-starter / src / client / app / shared / services / firebase-storage.service.ts View on Github external
return new Promise((resolve, reject) => {
            // Create a storage ref
            const fileName = `${file.name.split('.')[0]}-${randomStringGenerator()}.${file.name.split('.')[1]}`;
            const storageRef = app(environment.firebase.projectId).storage().ref(`${folderName || this.folderName}/${fileName}`);

            // Upload file
            const task: storage.UploadTask = storageRef.put(file, {
                cacheControl: 'public,max-age=300'
            });

            task.on(storage.TaskEvent.STATE_CHANGED, (snapshot: storage.UploadTaskSnapshot) => {
                onProgress(Math.round((snapshot.bytesTransferred / snapshot.totalBytes) * 100));

                switch (snapshot.state) {
                    case storage.TaskState.PAUSED:
                        break;

                    case storage.TaskState.RUNNING:
                        break;
                }
github giladv / orkan / src / orkan / firebase-auth / index.js View on Github external
handleProviderClick(provider){
		const firebaseProvider = this.firebaseProviders[provider];
		firebase.auth(firebase.app(FIREBASE_APP_NAME)).signInWithPopup(firebaseProvider).then(function(result) {

		}).catch(function(error) {
			// Handle Errors here.
			var errorCode = error.code;
			var errorMessage = error.message;
			// The email of the user's account used.
			var email = error.email;
			// The firebase.auth.AuthCredential type that was used.
			var credential = error.credential;

		});
	}
github benwinding / react-admin-firebase / dist / firebaseDataProvider.js View on Github external
function FirebaseClient(firebaseConfig) {
        this.firebaseConfig = firebaseConfig;
        this.resources = {};
        if (!firebase.apps.length) {
            this.app = firebase.initializeApp(firebaseConfig);
        }
        else {
            this.app = firebase.app();
        }
        this.db = this.app.firestore();
    }
    FirebaseClient.prototype.parseFireStoreDocument = function (doc) {
github benwinding / react-admin-firebase / src / providers / database / firebase / FirebaseWrapper.ts View on Github external
function ObtainFirebaseApp(firebaseConfig: {}, options: RAFirebaseOptions) {
  if (options.app) {
    return options.app;
  }
  const isInitialized = !!firebase.apps.length;
  if (isInitialized) {
    const app = firebase.app();
    return app;
  } else {
    const app = firebase.initializeApp(firebaseConfig);
    return app;
  }
}
github unfold / react-firebase / src / Firebase.js View on Github external
getFirebaseApp(props = this.props, context = this.context) {
    return props.firebaseApp || context.firebaseApp || firebase.app()
  }
github unfold / react-firebase / src / connect.js View on Github external
constructor(props, context) {
        super(props, context)

        this.firebaseApp = props.firebaseApp || context.firebaseApp || firebase.app()
        this.ref = path => this.firebaseApp.database().ref(path)
        this.state = {
          subscriptionsState: null,
        }
      }
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 huntercaron / firebase-data / FirebaseData.framerfx / code / FirebaseData.tsx View on Github external
const initializeApp = config => {
        firebase.initializeApp(config)
        return firebase.app()
    }
github giladv / orkan / src / orkan / media-gallery / index.js View on Github external
async handleRemove(key, media){
		const {orkan} = this.props;
		if(!confirm('are you sure?')){
			return;
		}
		let fileRef = firebase.storage(firebase.app(FIREBASE_APP_NAME)).ref(media.fullPath);
		fileRef.delete();

		const path = MEDIA_KEY_NAME + '/' + this.getMediaType(media.mimeType) + '/' + key;
		orkan.store.remove(path);

	}
github frontarm / navi / examples / firebase / src / Firebase.tsx View on Github external
constructor() {
    let app = firebase.apps.length !== 0 ? firebase.app() : firebase.initializeApp(config.firebase);

    this.auth = app.auth();
    this.db = app.database();
  }
}