Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
};
// A config file that contains your firebase project credentials (not included in the repo)
const CONFIG = tryRequire('./firebase-config.json') || {
apiKey: "AIzaSyAcq_Vr-wbCjctpWIXJdeXBHnQgSqCLRY8",
authDomain: "jellyfin-a9ff6.firebaseapp.com",
databaseURL: "https://jellyfin-a9ff6.firebaseio.com",
projectId: "jellyfin-a9ff6",
storageBucket: "",
messagingSenderId: "505439361090"
};
// Initialize Cloud Firestore through Firebase
const app = firebase.initializeApp(CONFIG);
const db = firebase.firestore();
// Disable deprecated features
db.settings({
timestampsInSnapshots: true,
});
// Add a document to a collection
db.collection("test-collection").add({
title: 'post title',
content: 'This is the test post content.',
date: new Date(),
})
.then(docRef => {
console.log('Document written with ID: ', docRef);
const connect = (props, dispatch) => {
console.log("Connecting to ", props.config, props.name)
const settings = { /* your settings... */
timestampsInSnapshots: true
};
const db = firebase.initializeApp(props.config, props.name).firestore()
db.settings(settings);
db.collection("/sessions").doc().set({
started: new Date()
})
console.log("dispatching", props.action)
dispatch(props.action)
}
return new Promise(async (resolve) => {
// We also save the user in the local storage to avoid a flickering in the GUI till Firebase as correctly fetched the user
const localUser: AuthUser = await get('deckdeckgo_auth_user');
this.authUserSubject.next(localUser);
firebase.initializeApp(EnvironmentConfigService.getInstance().get('firebase'));
firebase.auth().onAuthStateChanged(async (firebaseUser: FirebaseUser) => {
if (!firebaseUser) {
this.authUserSubject.next(null);
await del('deckdeckgo_auth_user');
await this.userService.signOut();
} else {
const tokenId: string = await firebaseUser.getIdToken();
const authUser: AuthUser = {
uid: firebaseUser.uid,
token: tokenId,
anonymous: firebaseUser.isAnonymous,
name: firebaseUser.displayName,
email: firebaseUser.email,
import rebase from "re-base";
import firebase from "@firebase/app";
import "@firebase/database";
const HN_DATABASE_URL = "https://hacker-news.firebaseio.com";
const HN_VERSION = "v0";
firebase.initializeApp({ databaseURL: HN_DATABASE_URL });
let db = firebase.database();
let base = rebase.createClass(db);
// Api is a wrapper around base, to include the version child path to the binding automatically.
const Api = {
/**
* One way data binding from Firebase to a component's state.
* @param {string} endpoint
* @param {object} options
* @return {object} An object which you can pass to 'removeBinding' if you want to remove the
* listener while the component is still mounted.
*/
bindToState(endpoint, options) {
return base.bindToState(`/${HN_VERSION}${endpoint}`, options);
},
import {h, Component} from 'preact';
import firebase from '@firebase/app';
import '@firebase/database';
import firebaseConfig from '../../../firebase-config';
import Button from '../components/button';
import {Input} from '../components/inputs';
import store from '../utils/store';
if (firebase.apps.length < 1) {
firebase.initializeApp(firebaseConfig);
}
class Sync extends Component {
constructor() {
super();
this.database = firebase.database();
this.handleNewConnection = this.handleNewConnection.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.onIcecandidate = this.onIcecandidate.bind(this);
this.onDatabaseChange = this.onDatabaseChange.bind(this);
this.handleConnect = this.handleConnect.bind(this);
this.handleSync = this.handleSync.bind(this);
this.peerConnection = new RTCPeerConnection();
import "@firebase/auth";
import "@firebase/database";
import "@firebase/storage";
import "@firebase/firestore";
import firebaseKey from "./keys/firebase.js";
let config = {
apiKey: firebaseKey,
authDomain: "myrjsecg.firebaseapp.com",
databaseURL: "https://myrjsecg.firebaseio.com",
projectId: "myrjsecg",
storageBucket: "gs://myrjsecg.appspot.com",
messagingSenderId: "967963389163"
};
firebase.initializeApp(config);
export default firebase;
export const provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({
prompt: "select_account"
});
export const auth = firebase.auth();
export const db = firebase.firestore();
export const scenes = db.collection("scenes");
export const snaps = db.collection("snaps");
export const classes = db.collection("classes");
export const storageRef = firebase.storage().ref();
import App from './App';
import app from '@firebase/app';
import React from 'react';
import ReactDOM from 'react-dom';
import initFirestore, { Provider } from 'react-stateful-firestore';
import { Route, BrowserRouter as Router } from 'react-router-dom';
const myApp = app.initializeApp({
apiKey: '',
authDomain: '',
databaseURL: '',
projectId: '',
storageBucket: '',
messagingSenderId: ''
});
const rootEl = document.getElementById('root');
initFirestore(myApp).then((store) => {
if (rootEl) {
ReactDOM.render(
export function _firebaseAppFactory(config: FirebaseAppConfig, appName?: string): FirebaseApp {
try {
if (appName) {
return firebase.initializeApp(config, appName) as FirebaseApp;
} else {
return firebase.initializeApp(config) as FirebaseApp;
}
}
catch (e) {
if (e.code === "app/duplicate-app") {
return firebase.app(e.name) as FirebaseApp;
}
return firebase.app(null!) as FirebaseApp;
}
}
export function _firebaseAppFactory(config: FirebaseAppConfig, appName?: string): FirebaseApp {
try {
if (appName) {
return firebase.initializeApp(config, appName) as FirebaseApp;
} else {
return firebase.initializeApp(config) as FirebaseApp;
}
}
catch (e) {
if (e.code === "app/duplicate-app") {
return firebase.app(e.name) as FirebaseApp;
}
return firebase.app(null!) as FirebaseApp;
}
}
constructor() {
if (!instance) {
this.app = firebase.initializeApp(config);
instance = this;
}
return instance;
}
}