ParmeJon / Terrace-Chat-2.0

1 stars 0 forks source link

Research Firebase Cloud functions implementation #2

Open ParmeJon opened 3 years ago

ParmeJon commented 3 years ago

What? Need investigation on how to implement Firebase with regards to custom cloud functions.

Why? We are going to need custom logic to determine when a person gets put into a new room.

ParmeJon commented 3 years ago

Firebase Cloud functions can be implemented in a node environment with their Firebase CLI.

CONS

  1. One issue with using custom cloud functions with Firebase is that you need to use a pay-as-you-go-plan. This can be found in their documentation:

    Note: You can emulate functions in any Firebase project, but to deploy to the recommended Node.js 10 runtime environment, your project must be on the Blaze pay-as-you-go billing plan. See Cloud Functions pricing.

  2. I believe some cloud functions will be slow in the beginning if not invoked often.

PROS

  1. You have easy access to all the built in Firebase APIs that like Realtime Database, Authentication and etc.
  2. Fast prototyping.

Resources: Cloud Function Use Cases Pros and Cons of Firebase More pros and cons

itspanicky commented 3 years ago

/src/lib/firebase.js

import firebase from "firebase";

const firebaseConfig = {
  apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
  authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
  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,
};

const initFirebase = firebase.initializeApp(firebaseConfig);
const db = initFirebase.firestore();

export default db;

Source: Setting up a react/firebase app