将Cloud Code与Parse Server和Heroku一起使用 [英] Using Cloud Code with the Parse Server and Heroku

查看:120
本文介绍了将Cloud Code与Parse Server和Heroku一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解新的Parse Server并已部署在Heroku上。这很顺利,但我正在努力解决如何编写服务器端代码(Cloud Code)。我已经多次阅读了解析服务器示例,所以我必须遗漏一些东西,但我不清楚我是否应该使用Express,或者我是如何开始包含我的Cloud Code文件的。非常感谢任何帮助。

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.

更新:

我找到了我刚刚查看的云文件夹错误的地方。我将它和index.js移动到桌面上的apps文件夹中。我已将main.js中的默认代码更改为自定义代码。我已经使用我的应用信息设置了index.js。现在的问题是,当我运行应用程序并尝试调用云代码函数时,我得到错误无效函数。

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.

推荐答案

如果你让heroku上运行的解析服务器示例你在那里是90%。只需打开 cloud / main.js 文件,然后开始添加您的云代码。这里应该有一个hello云函数作为例子。

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.

要使用已创建的云代码模块/文件,您可以像之前在parse.com上那样使用它们。唯一的区别是路径现在应该是相对的而不是绝对的。例如 require('cloud / cloudFunctions'); 应该是 require('。/ cloudFunctions'); 如果你在云目录中有一个名为 cloudFunctions.js 的模块。

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的工作原理类似于 parse.com 并且您不必为简单的应用程序考虑过多的表达式。也就是说,解析服务器正在使用expressjs,所以是的,你正在使用它。

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.

解析服务器只是另一个节点模块,类似于其他数千个可用的节点模块。如果您以前没有使用nodejs的经验,那么运行解析服务器看起来很复杂。因此,我建议在完全迁移之前阅读有关nodejs的基础知识。

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.

这篇关于将Cloud Code与Parse Server和Heroku一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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