UNLV-CS472-672 / 2024-S-GROUP5-Munch

The Munch app is a social platform where users create profiles by selecting preferred foods.
1 stars 11 forks source link

Firebase Emulator For Development #65

Closed rparker2003 closed 5 months ago

rparker2003 commented 5 months ago

Describe the bug

To Reproduce Steps to reproduce the behavior:

  1. Run the test suite in the backend server and note the increase of usage in the Firebase Console.

Screenshots

rparker2003 commented 5 months ago

Setting Up Firebase Emulator Suite with Flask

  1. Check Firebase CLI Installation:

    • Open terminal and run:
      firebase --version
    • If not installed, run:
      npm install -g firebase-tools
  2. Log in to Firebase:

    • Follow the instructions to log in to your Firebase account. (Google MunchApp2024 Account)
      firebase login
  3. Initialize Firebase Project:

    • In the backend directory, run:
      firebase init
    • Follow prompts, select Firestore service, use default file locations.
  4. Install Firebase Emulator Suite:

    • In the backend directory, run:
      firebase setup:emulators:firestore
  5. Add Environment Variables:

    • Open the backend .env file, and add:
      FIRESTORE_EMULATOR_HOST="127.0.0.1:8080"
      GCLOUD_PROJECT="munch-37564"
  6. Start Firebase Emulator:

    • Run the command:
      firebase emulators:start
  7. Start Flask Server:

    • Start the backend server, run:
      python server.py
  8. Test the Routes:

    • Go to http://127.0.0.1:4000/firestore in your web browser to see Firebase Emulator Suite website.
    • Test any route at address http://127.0.0.1:5000/api/ and verify the code is interacting with Firebase Emulator instead of the Cloud Firestore Database.