cloud code /Parse migration
hello... i didn't change the code of parse-server-example and i write my cloudcode in 'main.js' inside the folder 'cloud' of parse-server-example but the cloud code doesn't work when i do the migration!!! Any ideas?? the code : var api = new ParseServer({ databaseURI: databaseUri || 'mongodb://localhost:27017/dev', cloud: process.env.CLOUD_CODE_MAIN || __dirname + 'cloud/main.js', ....etc}
You seem to have left default database name mongodb://localhost:27017/dev.
dev should be replaced by your db name.
Otherwise, when you say it doesn't work, what do you mean ?
@Tibabal . i think "dev" is not the the issue here, He can actually have a mongo db name with such keyword. @mariamrostom "Copy your app’s Cloud Code to the parse-server/cloud directory, replacing the example main.js. You will need to replace any relative paths like ‘cloud/…’ to ‘./cloud’. " _ source_ [https://parse.com/docs/server/guide#deploying]
thanks all .everything is ok now
@mariamrostom How did you get this working? I have placed my cloud code in main.js, but methods like Parse.Cloud.beforeSave(), and afterSave() never get called.
@oyvindvol 1- open package.json in your parse-server-example repository and check if you have installed the right versions of necessary packages 2- if you are calling services from your code, install the node modules for each service that you use. foe exp,If you use stripe/mailgun or any other package, add them in your package.json file and run npm install. Then include them in your main.js file with the require('packageName'). 3- check if your parse-server on heroku is running ..because in my case, it was an internet error nothing else... I hope this helps you
@mariamrostom Thanks. What are the right packages, and the right versions, then? I have this:
"express": "~4.2.x",
"kerberos": "~0.0.x",
"parse": "~1.6.12",
"parse-server": "~2.0.8"
I don`t call any services from my cloud code at the moment, just stripped it down to the bare minimum (console logging) to get it working in the first place. Do you have to do Parse.Initialize() or set the serverURL or masterKey in your main.js?
1- For main.js, I only write the cloud code (the same cloud code as before the migration). NO Parse.Initialize() or set the serverURL or masterKey in main.js 2- This is my package.son file : "dependencies": { "express": "~4.2.x", "kerberos": "~0.0.x", "parse": "~1.6.12", "parse-server": "~2.0" } Try this, in your cmd , $ cd " your server folder" $ npm install ... it will install the necessary packages for you
I don`t get this, we have almost the exact same config. Would you mind posting your index.js, and some of your main.js as well?
Are you hosting it on Heroku?
Thank you very much so far..
1)sry, i forget to display the installed packages on my mac : $ npm ls ├── [email protected] ├── [email protected] ├─┬ [email protected] ├─┬ [email protected]
$ node --version v4.2.6 $ npm --version 2.14.12 2) yes , i use heroku
Hello Guys My cloud code is not working. can you please tell me how can I run that. The default hello function is calling from my ios app. But when I add new function and commit to heroku again. It shows "Invaild function". How can i commit latest code from 'cloud/main.js' to heroku app. After adding new code in 'cloud/main.js' I ran these commands. $ git add index.js $ git commit -m "Changed configuration values" // which shows
On branch master Your branch is ahead of 'origin/master' by 5 commits. (use "git push" to publish your local commits) Changes not staged for commit: modified: cloud/main.js modified: package.json
no changes added to commit
$ git push heroku master // last run
Does anyone have the following problem:
{ "code": 141, "error": "Invalid function." }
My parse-server is hosted on Heroku and I'm trying to call the functions in my cloud code.