Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import firebase from 'firebase'
try {
firebase.initializeApp({
databaseURL: 'https://hacker-news.firebaseio.com',
})
} catch (err) {
// we skip the "already exists" message which is
// not an actual error when we're hot-reloading
if (!/already exists/.test(err.message)) {
console.error('Firebase initialization error', err.stack)
}
}
const root = firebase.database().ref('v0')
export default root
onSubmit = async (values: FormValues) => {
try {
const { navigation } = this.props;
const user = navigation.getParam("userData");
values.age = new Date().getFullYear() - values.birthday.getFullYear();
delete values.birthday;
if (user) {
await firebase
.database()
.ref(`users/${user.uid}`)
.set({
...values,
description: "",
profileImage: user.photoURL,
lastActiveTime: Date.now(),
country: Localization.country
});
navigation.navigate(getNavigationKey(["chat", "home"]));
}
} catch (error) {
console.log(error);
}
};
exports.addUserToDatabase = functions.auth.user().onCreate(event => {
const user = event.data;
const userData = firebase.database().ref(`/users/${user.uid}`);
console.log(user);
return userData
.set(user)
.catch(e => {
console.error(e);
throw e;
});
});
firebase.database().ref('/scores/' + this.user.uid).once('value').then((snapshot) => {
const previousScore = snapshot.val()
if (!previousScore || (previousScore && this.shouldSaveNewScore(objToDb, previousScore))) {
firebase.database().ref('scores/' + this.user.uid).set(objToDb)
}
})
}
* Created by peter on 5/16/16.
*/
import promiseTry from 'es6-promise-try';
import firebase from 'firebase';
import { BLACK, WHITE } from './color';
firebase.initializeApp({
apiKey: 'AIzaSyD1sB2mtSubsImIEh4SklU7EivMnJHKLDA',
authDomain: 'vuego.firebaseapp.com',
databaseURL: 'https://vuego.firebaseio.com',
storageBucket: 'project-1396985000601130379.appspot.com'
});
let fb = firebase.database();
class RemoteGame {
constructor (store) {
this.store = store;
let gameId = store.state.remoteGameId;
if (!store.state[WHITE]) {
let opponent = fb.ref(`games/${gameId}/${WHITE}`);
let cb = snapshot => {
if (!snapshot.val()) {
return;
}
store.dispatch('remoteOpponentAccepted', { opponentId: snapshot.val() });
opponent.off('value', cb);
};
const initializeResource = ({ name, isPublic }, resolve) => {
let ref = (resourcesReferences[name] = firebase.database().ref(resourcesPaths[name]));
resourcesData[name] = [];
if (isPublic) {
subscribeResource(ref, name, resolve);
} else {
firebase.auth().onAuthStateChanged(auth => {
if (auth) {
subscribeResource(ref, name, resolve);
}
});
}
setTimeout(resolve, initialQuerytimeout);
return true;
};
import {FirebaseAdapter} from 'js-data-firebase'
import firebase from 'firebase'
const dataSource = 'firebase'
let config = {
apiKey: 'AIzaSyBnrMHd4NrB3ldmvtvWBp3dnRY8BJjTOpE',
authDomain: 'rateissue.firebaseapp.com',
databaseURL: 'https://rateissue.firebaseio.com',
storageBucket: 'rateissue.appspot.com',
messagingSenderId: '442562743753'
}
firebase.initializeApp(config)
const adapter = new FirebaseAdapter({
db: firebase.database()
})
export default adapter
export {dataSource, firebase}
export function getFirebaseInfo(appName) {
if (global.serverFirebase) {
//firebase-admin
return {app: null, ref: global.serverFirebase.database().ref()}
} else {
const fbApp = initFirebaseApp(appName)
return {app: fbApp, ref: firebase.database(fbApp).ref()}
}
}
'use strict';
var Firebase = require('firebase');
var firebaseConfig = require(__app + 'config')('firebase');
Firebase.initializeApp(firebaseConfig);
var firebaseDatabase = Firebase.database();
var games;
var initialisationState = 0;
module.exports = {
getPlayers: function () {
return new Promise(function (resolve) {
firebaseDatabase.ref('/players/').on('value', function (snapshot) {
resolve(snapshot.val());
});
});
},
getNewGamesListener: function (handler) {
var self = this;