问题
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!
回答1:
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
});
来源:https://stackoverflow.com/questions/35738765/implementing-cloud-code-on-open-source-parse-server