Cloud Function configuration and Publish

Video is outdated - view it for reference. follow written docs. 

In the project you downloaded from CodeCanyon there is a folder with name Cloud Functions

NlLJ9ujFuf6pdPDNl2GFCof3FaWsx3xScehT2vTL.png

Inside this folder, we have put all the Firebase Cloud Functions that are necessary for running the React App Builder Saas functionalities and also helper function that the App Needs. 


Publish Firebase Cloud Functions

First, you will need to have Firebase Tools installed.

sudo npm install -g firebase-tools


Open the folder CloudFunction folder in terminal

Run the following sequence of commands, one by one


Initialize Firebase 

firebase login
firebase init

Answer on the following questions

  1. Select Firebase Cloud Function with the Space Bar
  2. Select a default Firebase project for this directory:  -- Select your Firebase Instance
  3. What language would you like to use to write Cloud Functions?  -- JavaScript
  4. Do you want to use ESLint to catch probable bugs and enforce style? (y/N) - N
  5. File functions/package.json already exists. Overwrite? (y/N) - N
  6. File functions/index.js already exists. Overwrite? (y/N) - N
  7. File functions/.gitignore already exists. Overwrite? (y/N) - N
  8. Do you want to install dependencies with npm now? (Y/n)- y    <-- This will install the npm modules for Firebase

You will something like

Writing configuration info to firebase.json...
Writing project information to .firebaserc...
✔ Firebase initialization complete!


Now go inside the funcitons folder

cd functions

Then install the modules needed

npm install

Then upload the Functions to Firebase

firebase deploy --only functions


You will see something like


i  deploying functions
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (56.79 KB) for uploading
✔ functions: functions folder uploaded successfully
i functions: updating Node.js 6 function sendNotifyEmail(us-central1)...
i functions: updating Node.js 6 function crypteTheApplePassword(us-central1)...
i functions: updating Node.js 6 function saveAsGeostore(us-central1)...
i functions: updating Node.js 6 function paddleIntegration(us-central1)...
i functions: updating Node.js 6 function advancedSearch(us-central1)...
i functions: updating Node.js 6 function generateThumbnail(us-central1)...
i functions: updating Node.js 6 function saveVideoImage(us-central1)...
i functions: updating Node.js 6 function updateEventDateStartEndTime(us-central1)...
✔ functions[advancedSearch(us-central1)]: Successful update operation.
✔ functions[crypteTheApplePassword(us-central1)]: Successful update operation.
✔ functions[saveAsGeostore(us-central1)]: Successful update operation.
✔ functions[generateThumbnail(us-central1)]: Successful update operation.
✔ functions[sendNotifyEmail(us-central1)]: Successful update operation.
✔ functions[saveVideoImage(us-central1)]: Successful update operation.
✔ functions[paddleIntegration(us-central1)]: Successful update operation.
✔ functions[updateEventDateStartEndTime(us-central1)]: Successful update operation.


And you are done with uploading the cloud functions to Firestore.


Cron Jobs ( new )

Some function is required to be called on an interval. Example the syncing function for Radio, Shopify Data and Wordpress Data (soon). 

That is why we need to define our own schedule of calling these functions.


Cron Job Caller

You have the following options to create cron jobs. 

1. Google Shuduler - https://cloud.google.com/scheduler/ ( free quota of three (3) jobs per month ) 

2. Your hosting Cron - If you have your own hosting, it is common that you can create cron jobs.

3. Use other 3rd part cloud cron caller ex. https://cron-job.org/en/ or https://azure.microsoft.com/en-us/services/scheduler/ or search for any other. 


Cron Job creation

Let's create a cron job. First, you need to go in your firebase functions and location the HTTP function that needs to be called.

JR2pjjPYvoSrgawwgE4Ow71y39h204of9hf9lDFC.png


Copy the function link. And create a cron job on an interval you wish. ex. every 1min

This can help

https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules


The corn in Google Scheduler Can look like this

qSw4WRN6elU71nqJIatfYrr5Od7pAkDv8azK3l6U.png

Now my radios data will update every 1 min. 


You should do cron jobs for Shopify Sync And Radio Sync. 

For shopify sync, the sync interval can be bigger, ex. 1hour or more.







Next:

Declare the React App Builder as SaaS