0

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 achieve Commented 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. Commented 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 same Commented 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! Commented Mar 2, 2016 at 5:37

1 Answer 1

3

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
});
Sign up to request clarification or add additional context in comments.

5 Comments

I can't seem to find index.js anywhere.
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
@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?
@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?
Ive not followed parse server from long ago now but i remember you have to create the file of own

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.