Functions

F Firebase, Syncing and Functions / Cloud Functions Last updated on Updated  Mar 12, 2019

 After upload, you will have the following function in Cloud Functions

NOTE: For every command that is needed for these cloud functions to be runned from the terminal or cmd, you have to be sure that you are running the command into the correct folder. The correct path is  cloud_functions -> functions

  1. sendNotifyEmail

     Function for sending emails to clients and deleting queue object

     Configuration
  • Then follow the instructions for creating the sandgrid account and getting an API_KEY.
  • After when you get API_KEY open the cloud_function project and in the functions folder you should see the config.js file. In this file around line 2, you should see a variable called SENDGRID_API_KEY. The value of this variable replaces it with the value of the API_KEY that you get from sandgrid.
//The Sendgrid KEY --- CHANGE THEM WITH YOUR OWN SENDGRID
exports.SENDGRID_API_KEY="YOUR_SENDGRID_API_KEY";
  • And the final step, in the same folder from the previous step in the config.js file around line 4  you should change the email address with yours
//Email Config
exports.fromEmail="YOUR_EMAIL_ADDRESS";

 2. saveAsGeostore

    A function that creates or update geofirex object in firestore when the document is created  or update.


 3. paddleIntegration

     Function for creating or update the information.

 4. advancedSearch

    - Function for searching  into the documents in firestore by:

  • their location for a given radius, 
  • category - optional
  • query - optional

    Configuration

  • Into the config. js file around line 15, there is variable called configApp, open the Firebase console. Then go in Project settings, and click on "Add Firebase to your web app"

                                                       WRsUzeYok4sassslC5HZoMT5guwpCd0l7yOOoHGK.png

        Then copy the config string. 

                                                        PvX197CuF46tXR2DUJq1Idhd9x3gLMDUkeVi9JVd.png

         And replace it in the config.js file in the value of the variable configApp.

//Firebase configuration
exports.configApp = {
    apiKey: "your_apiKey",
    authDomain: "your_authDomain",
    databaseURL: "your_databaseURL",
    projectId: "your_projectId",
    storageBucket: "your_storageBucket",
    messagingSenderId: "your_messagingSenderId"
  };



 5. generateThumbnail

    - Function for generating a thumbnail image for every uploaded image

        The thumbnail generation is performed using ImageMagick which is installed by default on all Cloud Functions         instances. This is a CLI so we execute the command from the node using the child-process-promise package.            The image is first downloaded locally from the Cloud Storage bucket to the tmp folder using the google-cloud         SDK.

 6. saveVideoImage

    - Function for generating an image from the youtube video if the document is having videoLink field

   

 7. updateEventDateStartEndTime

  - Function for update the EventDateStartEndTime field in the document in firestore if the eventStart and eventEnd     fields are updated or created