在开源解析服务器上实现云代码 [英] Implementing Cloud Code on Open Source Parse Server

查看:117
本文介绍了在开源解析服务器上实现云代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新的Parse Server开发应用程序.我已经研究了很多,但无法弄清楚.我想运行一些服务器端代码(云代码),但我什至无法弄清楚如何使用Heroku和Mongo创建云代码文件.非常感谢您的帮助!

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!

推荐答案

在应用程序的根目录中,创建一个云文件夹,并在该文件夹中创建一个main.js文件,并将示例内容复制到该文件中

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

然后在您的Index.js中提及该文件在config中的路径

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

这篇关于在开源解析服务器上实现云代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆