01Riv
01Riv

Reputation: 1454

Implementing Cloud Code on Open Source Parse Server

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!

Upvotes: 0

Views: 433

Answers (1)

Ajay Singh Beniwal
Ajay Singh Beniwal

Reputation: 19037

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
});

Upvotes: 3

Related Questions