Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
authDomain: config.firebase.authDomain,
databaseURL: config.firebase.databaseURL,
projectId: config.firebase.projectId,
storageBucket: config.firebase.storageBucket,
messagingSenderId: config.firebase.messagingSenderId
}
firebase.initializeApp(firebaseConfig)
} catch (error) {
console.log('=========Firebase firestore initializer==============')
console.log(error)
console.log('====================================')
}
// - Storage reference
export let storageRef = firebase.storage().ref()
// Initialize Cloud Firestore through Firebase
const db = firebase.firestore()
const settings = {}
db.settings(settings)
export {
db
}
// - Database authorize
export let firebaseAuth = firebase.auth
export let functions = firebase.functions()
// export let firebaseRef = firebase.database().ref()
// - Firebase default
export default firebase
uploadFeaturedImage(e, fieldName) {
this.isLoading = true;
let file = e.target.files[0];
let storageRef = firebase.storage().ref("images/" + file.name)
storageRef.put(file).then(snapshot => {
snapshot.ref
.getDownloadURL()
.then(downloadURL => {
this.$set(this, "imagePreview", URL.createObjectURL(file))
this.newContent[fieldName] = ""
this.newContent[fieldName] = downloadURL
if (
Object.values(this.media).find(
e => e.path === snapshot.ref.fullPath
)
)
return; // this prevents duplicate entries in the media object
this.$firebaseRefs.media.push({
src: downloadURL,
uploadFeaturedImage (e) {
let file = e.target.files[0]
let storageRef = firebase.storage().ref('images/' + file.name)
storageRef.put(file).then((snapshot) => {
snapshot.ref.getDownloadURL().then(downloadURL => {
this.content.img = downloadURL
if (Object.values(this.media).find(e => e.path === snapshot.ref.fullPath)) return // this prevents duplicate entries in the media object
this.$firebaseRefs.media.push({
src: downloadURL,
path: snapshot.ref.fullPath,
name: snapshot.metadata.name
})
})
})
},
styleTags (fieldName) {
deleteImageRef() {
let storage = firebase.storage();
let imageRef = storage.refFromURL(this.imageUrl);
let me = this;
imageRef.delete().then(function() {
me.imageUrl = null;
}).catch(function(error) {
console.log('error', error);
});
}
deleteImageRef() {
let storage = firebase.storage();
let imageRef = storage.refFromURL(this.imageUrl);
let me = this;
imageRef.delete().then(function() {
me.imageUrl = null;
}).catch(function(error) {
console.log('error', error);
});
}
return new Promise((resolve, reject) => {
let storageRef = firebase.storage().ref();
let imageRef = storageRef.child('image').child('imageName');
this.encodeImageUri(imageURI, function(image64){
imageRef.putString(image64, 'data_url')
.then(snapshot => {
resolve(snapshot.downloadURL)
}, err => {
reject(err);
})
})
})
}
this.store = function (path) {
return firebase.storage().ref(path)
}
}
firebase.initializeApp({
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL,
projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.REACT_APP_FIREBASE_APP_ID,
measurementId: process.env.REACT_APP_FIREBASE_MEASUREMENT_ID
});
export default firebase;
export const analytics = firebase.analytics();
export const auth = firebase.auth();
export const firestore = firebase.firestore();
export const storage = firebase.storage();
export const performance = firebase.performance();
uploadFields.map(fieldName =>
firebase.storage().ref().child(`${resourcePath}/${id}/${fieldName}`).delete())
}
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();