I am developing an app using the new Parse Server. I have researched quite a bit, but cannot figure this out. I want to run some server side code (Cloud Code) but I cannot figure out how to even create a Cloud Code file using Heroku and Mongo. Any help is very much appreciated!
4
-
what do you want to achieveAjay Singh Beniwal– Ajay Singh Beniwal2016-03-02 05:15:13 +00:00Commented Mar 2, 2016 at 5:15
-
I want to be able to call a cloud code function. I had this working with the hosted Parse but I'm not sure how to make a cloud code file with the open source Parse Server running on Heroku so that I can call Cloud Code functions from it.01Riv– 01Riv2016-03-02 05:17:51 +00:00Commented Mar 2, 2016 at 5:17
-
you just need to mention serverURL and path to your cloud file while setting up parse server and rest everything remains sameAjay Singh Beniwal– Ajay Singh Beniwal2016-03-02 05:35:22 +00:00Commented Mar 2, 2016 at 5:35
-
Can you explain to me how to add the path to my cloud code file if I have already set up parse server. Or point me in the direction of any documentation for this. Also, thank you!01Riv– 01Riv2016-03-02 05:37:42 +00:00Commented Mar 2, 2016 at 5:37
Add a comment
|
1 Answer
In the root of app create a cloud folder and create a main.js file in that folder and copy the sample contents in the file
Parse.Cloud.define('hello', function(req, res) {
res.success('Hi');
});
Then in your Index.js mention the path of this file in config
var api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dev',
cloud: __dirname + '/cloud/main.js',
appId: 'myAppId',
masterKey: '', //Add your master key here. Keep it secret!
serverURL: 'http://localhost:1337' // Don't forget to change to https if needed
});
5 Comments
01Riv
I can't seem to find index.js anywhere.
Ajay Singh Beniwal
index.js is just sample name you will have one js file which will bootstrap your parse server check this out github.com/ParsePlatform/parse-server-example
quarks
@AjayBeniwal the problem I see here is that you need to deploy / re-deploy your application every time cloud code needs to be changed, any way to create cloud code from the dashboard?
Byron Coetsee
@AjayBeniwal those of us who deployed directly to Heroku with the "Deploy to Heroku" button don't have this index.js file... Should we create it?
Ajay Singh Beniwal
Ive not followed parse server from long ago now but i remember you have to create the file of own