How to use the firebase/app.functions 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 bpetetot / conference-hall / src / store / reactions / firebase.js View on Github external
export const init = (action, store) => {
  try {
    firebase.initializeApp(config)

    // enable firestore
    firebase.firestore()

    // enable function calls
    firebase.functions()
    initFunctionCalls()
  } catch (error) {
    console.warn(error.code, error.message)
  }

  firebase.auth().onAuthStateChanged(user => {
    if (user) {
      store.dispatch({ type: '@@firebase/SIGNED_IN', payload: user })
      preloadFunctions()
    } else {
      store.dispatch('@@firebase/SIGNED_OUT')
    }
  })
}
github red-gold / react-social-network / src / data / firestoreClient / index.ts View on Github external
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
github nwplus / nwhacks2019 / web / services / store / index.js View on Github external
export default (initialState = {}) => {
  // Pick between dev and prod firebase configurations
  const selectedFirebaseConfig = firebaseConfig[process.env.NODE_ENV];

  // Initialize firebase instance
  firebase.initializeApp(selectedFirebaseConfig);

  // Initialize Cloud Functions to firebase instance
  firebase.functions();

  firebase.nwUtils = {
    // Define a function for fetching a cloud function's URL given its name
    getFunctionUrl: (functionName) => {
      if (process.env.NODE_ENV === 'development') {
        return `http://localhost:5000/${selectedFirebaseConfig.projectId}/us-central1/${functionName}`;
      } // production
      return `https://us-central1-${selectedFirebaseConfig.projectId}.cloudfunctions.net/${functionName}`;
    },
  };

  // Initialize Cloud Firestore through Firebase
  const firestore = firebase.firestore();
  const firestoreSettings = { timestampsInSnapshots: true };
  firestore.settings(firestoreSettings);
github CorayThan / archon-arena / src / index.tsx View on Github external
FontsConfig.loadFonts()

log.debug("init firebase")

firebase.initializeApp({
    apiKey: "AIzaSyDu0Zg8VmVa664dCTWErmcn3yDE1OJBfs0",
    authDomain: "forge-of-the-archons.firebaseapp.com",
    databaseURL: "https://forge-of-the-archons.firebaseio.com",
    projectId: "forge-of-the-archons",
    storageBucket: "forge-of-the-archons.appspot.com",
    messagingSenderId: "81787944178",
    appId: "1:81787944178:web:36aa683bc37bfedc"
})
if (isDev) {
    firebase.functions().useFunctionsEmulator("http://localhost:5000")
}

WebFont.load({
    google: {
        families: ["Roboto:300,400,500,700"]
    },
})

ReactDOM.render(, document.getElementById("root"))

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister()

authStore.listenForAuthUser()
github NUS-ALSET / achievements / src / services / adminCustomAnalysis.js View on Github external
async onAdminAnalyse(uid, adminCustomAnalysisID, queries) {
    try {
      let results = await this.getQueryResults(queries).then();
      return await firebase
        .functions()
        .httpsCallable("runCustomAnalysis")({
          uid,
          solutions: results,
          analysisID: adminCustomAnalysisID,
          analysisType: "adminCustomAnalysis"
        })
        .then(response =>
          this.storeAnalysis(uid, response, adminCustomAnalysisID)
        )
        .catch(err => console.error(err));
    } catch (error) {
      console.error(error.message);
    }
  }
}
github yarnaimo / vanilla-clipper / web / src / utils / firebase.ts View on Github external
import * as firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'
import 'firebase/functions'
import { firebaseConfig } from '../.config/firebase'

firebase.initializeApp(firebaseConfig)

export const db = firebase.firestore()

export const functions = firebase.functions()

export const authProvider = new firebase.auth.GoogleAuthProvider()
github 0918nobita / Tsundoku / client / src / pages / bookshelf / search-by-isbn-modal / search-by-isbn-modal.ts View on Github external
async add(isbn: string) {
    try {
      await Promise.all([
        firebase.functions().httpsCallable('registerBook')({
          uid: (firebase.auth().currentUser as firebase.User).uid,
          isbn
        }),
        this.dismiss()
      ]);
    } catch (error) {
      await this.showError(error);
    }
  }
}
github bpetetot / conference-hall / src / firebase / functionCalls.js View on Github external
const buildFunctionWithTimezone = functionName => {
  const cloudFunction = firebase.functions().httpsCallable(functionName)
  const { timeZone } = Intl.DateTimeFormat().resolvedOptions()

  return ({ userTimezone, ...rest }) =>
    cloudFunction({
      ...rest,
      userTimezone: userTimezone || timeZone,
    })
}
github AntlerVC / firetable / www / src / firebase / index.ts View on Github external
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();
github mpigsley / sectors-without-number / src / store / api / entity.js View on Github external
export const uploadEntities = (entities, sectorId) =>
  Firebase.functions()
    .httpsCallable('saveEntities')({ sectorId, entities })
    .then(({ data }) => data);