Using Cloud Code with the Parse Server and Heroku

Using Cloud Code with the Parse Server and Heroku

If you have the parse server example running on heroku you are 90 percent there. Just open the cloud/main.js file and start adding your cloud code. There should be a hello cloud function there as an example.

To use your already created cloud code modules/files you can require them as you have done before on parse.com. The only difference is that the path should now be relative instead of absolute. For example require('cloud/cloudFunctions'); should be require('./cloudFunctions'); if you had a module called cloudFunctions.js in the cloud directory.

Cloud Code works similar to how it did on parse.com and you shouldn't have to think too much about expressjs for simple applications. That said, parse server is using expressjs so yes you are using it.

Parse server is simply a another node module similar to the other thousands available. If you do not have previous experience with nodejs, running parse server can seem complicated. Therefore I would recommend reading about the basics of nodejs before a full migration.

Using Cloud Code with the Parse Server and Heroku

If you have the parse server example running on heroku you are 90 percent there. Just open the cloud/main.js file and start adding your cloud code. There should be a hello cloud function there as an example.

To use your already created cloud code modules/files you can require them as you have done before on parse.com. The only difference is that the path should now be relative instead of absolute. For example require('cloud/cloudFunctions'); should be require('./cloudFunctions'); if you had a module called cloudFunctions.js in the cloud directory.

Cloud Code works similar to how it did on parse.com and you shouldn't have to think too much about expressjs for simple applications. That said, parse server is using expressjs so yes you are using it.

Parse server is simply a another node module similar to the other thousands available. If you do not have previous experience with nodejs, running parse server can seem complicated. Therefore I would recommend reading about the basics of nodejs before a full migration.

How to use cloud code on parse server deployed on heroku?

I was having the same issue here is the way to put the latest code from 'cloud/main.js' to heroku from terminal

 $ git add ./cloud/main.js
$ git commit -m "Changed configuration values"
$ git push heroku master

Now call your newly uploaded function from the app they will now work.

Push notifications, from Parse-Server cloud code

Try something like this:

Parse.Cloud.afterSave('Item_List', async () => {
const query = new Parse.Query(Parse.Installation);
query.equalTo('deviceType','ios');
await Parse.Push.send({
where: query,
data: { alert: 'NOTIFICATION-FOR-USERS' },
useMasterKey: true
});
});


Related Topics



Leave a reply



Submit