This repo constitutes the backend for the ILPlatform landing and curriculum page. It is built using Firebase Functions and connects to the Salesforce and Google API for database and document management.
In order for the code to make sense, you need to generate the following files:
functions/.googleapi_credentials.json- Can be obtained through the Google Cloud Console (Project: ILPlatform Website) under Credentials (search for it) > OAuth 2.0 Client IDs with type Web Application and redirect URI "http://localhost:8888/oauth2callback". Simply select pre-existing client and generate new client secret.functions/.googleapi_token.json- Can be obtained by running the server locally (see below) and calling any endpoint that requires the Google Connector. Ensure that all required scopes are activated in the Google API.functions/.firebase_adminsdk.json- Can be obtained through the Firebase Console under Project Settings > Service Accounts > Generate New Private Key.functions/.env- Contains the following environment variables:# Salesforce Login Details (to access database) SF_USERNAME= SF_PASSWORD= SF_SECURITY_TOKEN= # Gmail Login Details (to send emails) GMAIL_USER_EMAIL= GMAIL_PASSWORD= # WhatsApp Configuration WHATSAPP_ACCESS_TOKEN= WHATSAPP_PHONE_ID= # Google Drive Folder ID (public folder to store photos) DRIVE_CAMPS_PHOTOS_ID=
functions/venv- Contains the Python virtual environment for the backend. Can be created by runningAlternatively, runcd functions python3.12 -m venv venv source venv/bin/activate python3.12 -m pip install -r requirements.txt
source sh_create_env.sh.
In order to run the code, you need to run the following;
source functions/venv/bin/activate
firebase emulators:start --only functions
Alternatively, run source sh_start.sh.
An error of this style might occur:
⬢ functions: Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification. Timeout after 10000. See https://firebase.google.com/docs/functions/tips#avoid_deployment_timeouts_during_initialization'
To solve it, do the following:
npm i -g firebase-tools