Implementing Cloud Code on Open Source Parse Server

♀尐吖头ヾ 提交于 2019-12-12 03:33:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!