Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.push({
...data,
createdAt: {
".sv": "timestamp"
},
type: action.type,
uid: currentUserId,
version: process.env.REACT_APP_VERSION,
otherActionData: actionDataToSave
}).then((snap)=>{
firebase
.database()
.ref("/logged_events/"+snap.key).update(JSON.parse( JSON.stringify(objIndItems)))
});*/
const firestore_db = firebase.firestore();
// Added firestore related changes
firestore_db.collection("/logged_events").add({
...data,
createdAt: firebase.firestore.Timestamp.now().toMillis(),
type: action.type,
uid: currentUserId,
version: process.env.REACT_APP_VERSION,
otherActionData: actionDataToSave
}).then((snap)=>{
firestore_db.collection("/logged_events").doc(snap.id).update(JSON.parse( JSON.stringify(objIndItems)))
});
} catch (err) {
console.error(err, action);
}
}
initFirebase () {
try {
firebase.initializeApp(this.config.fireBase)
firebase.firestore().enablePersistence()
this.FBStorage = firebase.storage()
this.FBStorageRef = this.FBStorage.ref()
this.FBStorageCircuitRef = this.FBStorageRef.child('bitcoin_circuits')
this.FBStorageAudioRef = this.FBStorageRef.child('bitcoin_block_audio')
// await firebase.firestore().enablePersistence()
} catch (error) {
console.log(error)
}
this.firebaseDB = firebase.firestore()
// this.anonymousSignin()
// send ready event
firestore() {
if (!firebase.apps.length) firebase.initializeApp(clientCredentials)
var db = firebase.firestore()
db.settings({timestampsInSnapshots: true}) // Using Timestamps
return db
}
const firebase = require('firebase/app')
require('firebase/firestore')
firebase.initializeApp({ projectId: 'noop' })
const store = firebase.firestore()
store
.collection('users')
.get()
.then(
() => {
process.exit(0)
},
e => {
/*
Error: unresolvable extensions: 'extend google.protobuf.MethodOptions' in .google.api
at Root.resolveAll (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/node_modules/protobufjs/src/root.js:243:1)
at Object.loadSync (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/a707d6b7ee4afe5b484993180e617e2d/index.js:43406:16)
at loadProtos (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/a707d6b7ee4afe5b484993180e617e2d/index.js:16778:41)
at NodePlatform.module.exports.278.NodePlatform.loadConnection (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/a707d6b7ee4afe5b484993180e617e2d/index.js:16815:22)
at FirestoreClient.module.exports.278.FirestoreClient.initializeRest (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/a707d6b7ee4afe5b484993180e617e2d/index.js:28414:14)
import "firebase/firestore";
import "firebase/functions";
import "firebase/storage";
const config = {
apiKey: process.env.REACT_APP_FIREBASE_PROJECT_KEY,
authDomain: `${process.env.REACT_APP_FIREBASE_PROJECT_NAME}.firebaseapp.com`,
databaseURL: `https://${process.env.REACT_APP_FIREBASE_PROJECT_NAME}.firebaseio.com`,
projectId: process.env.REACT_APP_FIREBASE_PROJECT_NAME,
storageBucket: `${process.env.REACT_APP_FIREBASE_PROJECT_NAME}.appspot.com`,
};
firebase.initializeApp(config);
export const auth = firebase.auth();
export const db = firebase.firestore();
export const bucket = firebase.storage();
export const functions = firebase.functions();
export const googleProvider = new firebase.auth.GoogleAuthProvider();
export const fetchOrganizationEvents = organizationId =>
firebase
.firestore()
.collection('events')
.where('organization', '==', organizationId)
.get()
async saveVideoMetadata(metadata) {
const user_id = firebase.auth().currentUser.uid;
const videoRef = firebase.firestore().doc(`users/${user_id}`).collection('videos').doc();
metadata = Object.assign(metadata, { uid: videoRef.id });
await videoRef.set(metadata, { merge: true });
}
export default () => {
if (!firebase.apps.length) {
firebase.initializeApp(process.env.firebaseConfig);
}
const firestore = firebase.firestore();
const settings = {};
firestore.settings(settings);
}
const getInstance = (firebaseKeys) => {
if (loaded) {
return firestore;
}
firebase.initializeApp({
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
});
firestore = firebase.firestore();
firestore.settings({ timestampsInSnapshots: true });
loaded = true;
return firestore;
}
const createPost = values => {
ReactGA.event({
category: 'Post',
action: 'Create post',
})
values.slug = slugify(values.title, {lower: true})
values._likeCount = 0
return Firebase.firestore()
.collection('posts')
.add(prepareDocForCreate(values))
.then( () => values)
.catch( error => {
alert(`Whoops, couldn't create the post: ${error.message}`)
})
}