virtualMachineparse

Add custom cloud code to Parse Server

There are some cases where you may want to develop your own cloud code, so as to make Parse work in a non-standard way, or make it perform a desired operation when certains conditions are met. You can find more information about this in the Parse official documentation. In order to add your custom cloud code to your Parse Server stack, please follow the steps below:

  • Stop the Parse server:

      $ sudo /opt/bitnami/ctlscript.sh stop parse
    
  • Create a cloud directory in /opt/bitnami/apps/parse/htdocs/

      $ sudo mkdir -p /opt/bitnami/apps/parse/htdocs/cloud
    
  • Edit the script at /opt/bitnami/apps/parse/htdocs/

      $ cd /opt/bitnami/apps/parse/htdocs/
      $ vim server.js
    
  • Edit the ParseServer variable and modify the cloud object following the example below:

      var api = new ParseServer({
        databaseURI: "mongodb://root:MONGODB_PASSWORD@127.0.0.1:27017/bitnami_parse",
        cloud: "./cloud/main.js",
        appId: "APP_ID",
        masterKey: "MASTER_KEY",
        fileKey: "FILE_KEY",
        serverURL: 'http://SERVER-IP:80/parse'
        });
    

Remember to replace the MONGODB_PASSWORD, APP_ID, MASTER_KEY, FILE_KEY and SERVER-IP placeholders with your MongoDB administrator account password, application ID, application master key, application file key and server’s public IP address respectively.

  • Restart the Parse server:

      $ sudo /opt/bitnami/ctlscript.sh restart parse