1. Getting Started - leeteresamaria/RoomieMatter GitHub Wiki

To use the backend:

Installing Dependencies

First, make sure Node.js is installed. Once you install it, restart your computer.
Next, ensure you have access to the Firebase console (or setup a new firebase project)

Setting up a new Firebase Project?
If you are setting up a new Firebase Project, there are more steps for you to follow.

Setup The Console

First, you'll set up the console. Then, you will add the services we use in this project (Firestore, Functions, and Google Auth). This tutorial will walk through setting up Firebase for a swift app and adding Google Auth.

Setup The Database

You will then setup the Firestore Database. In the Firebase console click the build tab on the left navigation bar, then Firestore Database. In here you can add our schema.

Add our custom indexes as shown here:

283917212-5d12f9e1-ad54-4db8-8e94-fed0cfaf2d6a

Add our custom rules as shown here (These can be found under Server->rules.txt):

283917565-d8359d77-982f-4e6b-92a1-d19b44e627b1

Setup Functions

First, add functions to the project in the same way we added Firestore.
Then, follow the Setting up Firebase Functions section and To deploy to the backend.
Once these functions are deployed, follow this video to ensure they have the right permissions.


Setting up Firebase Functions

First, install the Firebase CLI and the project's dependencies
sudo npm install -g firebase-tools
cd /server/functions
npm install

You may run into an error here if node_modules or package-lock.json already exist. If you get this error, do the following, then try again.
rm -rf node_modules
rm -rf package-lock.json

Next you will login to Firebase and initialize the project
firebase login
firebase use --add

You may run into an error like zsh: permission denied: firebase. If this happens do the following, then try again.
which firebase to find out the directory firebase is in
sudo chmod +x {directory returned from previous command}

To deploy the backend:

firebase deploy --only functions

Google Cloud Project

Interactions with the Google Calendar API require a Google Cloud project for authentication and authorization settings. The creation of a Firebase project automatically creates a Google Cloud project. The Google Developers Node.js Quickstart document is helpful for properly setting up the Google Cloud project. Follow the instructions on Prerequisites and Enable the API. Ensure that the correct project is selected when working on Google Cloud project (the same name as the Firebase project created).

For configuring the OAuth consent screen, follow steps 1-3. In step 4, add the following scope for Google Calendar API:

  • API: Google Calendar API
  • Scope: .../auth/calendar.app.created
  • User-facing description: Make secondary Google calendars, and see, create, change, and delete events on them

Continue with steps 5 and 6.

Instead of authorizing credentials for a desktop application, we are authorizing for a web application:

  1. In the Google Cloud console, go to Menu > APIs & Services > Credentials
  2. Ensure that there's a Web client (auto created by Google Service) under OAuth 2.0 CLient IDs

This is all for the Google Cloud Project part.

When running the app for the first time, follow the instructions in step 2 of run the sample to allow proper access to the Google Calendar API.

Third Party Dependencies

⚠️ **GitHub.com Fallback** ⚠️