I am confused after reading Parse's documentation on Cloud Code. They say that Cloud Code is not a Node.js environment.
E.g when I call a cloud function from the client (In this case a iOS app).
PFCloud.callFunctionInBackground("testCloud", withParameters: [:]) {
(response: AnyObject?, error: NSError?) -> Void in
if (error == nil) {
if let testRespones = response as? String{
print(testRespones)
}
} else {
print(error)
}
}
My parse server is currently hosted on Heroku.
Any insight would be greatly appericated.
Your Cloud Code is literally just a javascript file running in a node.js server instance. When you make a request to the server for your Cloud Code your parse-server express app routes these request, denoted by /cloud, to your file in your cloud directory. In order for this to work you must set your cloud variable in your ParseServer object in index.js. Something like this
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js'
So basically when you call a cloud function you're calling the cloud variable in your parse-server which routes you to 'parse-server-directory/cloud/main.js' and finds your function and returns some kind of response.