I am trying to understand the new Parse Server and have deployed on Heroku. This went smoothly but what I am struggling with is figuring out how to write server side code (Cloud Code). I've read over the parse server example many times so I must be missing something but I'm very unclear if I should be using Express for something, or how I even begin to include my Cloud Code files. Any help is very much appreciated.
UPDATE:
I found the cloud folder I was just looking in the wrong place. I moved it and index.js to my apps folder on the desktop. I have changed the default code in main.js to my custom code. I have set up index.js with my apps information. The problem now is when I run the app and try to call the cloud code functions I get error invalid function.
Parse Server is a Parse API compatible Express router package and an alternative to the discontinued hosted Parse service. This guide shows you how to deploy and configure a Parse server on Heroku. A Heroku account is required, sign-up for free.
Cloud Code is easy to use because it’s built on the same Parse JavaScript SDK that powers thousands of apps. The only difference is that this code runs in your Parse Server rather than running on the user’s mobile device. When you update your Cloud Code, it becomes available to all mobile environments instantly.
To use the FSAdapter, simply initialize your Parse Server in index.js by doing the following: When using parse-server-fs-adapter across multiple Parse Server instances it’s important to establish “centralization” of your file storage (this is the same premise as the other file adapters, you are sending/recieving files through a dedicated link).
Starting 2.2.6, GCS Adapter is not provided by default by parse-server. To install run: Writing to your Google Cloud Storage bucket from Parse Server is as simple as configuring and using the GCS files adapter. You can use Google Cloud Storage to host your static files by setting the following environment variables:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With