云代码功能未使用Parse Server开源API执行 [英] Cloud code functions are not executing with Parse server open source API

查看:59
本文介绍了云代码功能未使用Parse Server开源API执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这是我的问题,我们正在开发一个移动应用程序,所以5个月前开始时,我们使用Parse作为我们的后端解决方案.现在Parse将在几个月后死亡,但幸运的是,我们仍然可以通过包含其API来使用Parse服务器.但是在mongo上迁移我们的数据库(这在过程中引起很多愤怒和绝望:p)并在AWS上托管服务器之后,我再也无法执行我的云代码了.找不到我定义的功能,并且由于Parse仪表板不再可用,我无法检查我的云功能是否已部署在服务器上.有人可以帮助我,告诉我我做错了什么吗?你们知道另一种检查云功能的方法吗? 这是我的index.js:

So here's my problem, we're developing a mobile app so 5 month ago when we began, we used Parse for our backend solution. Now Parse will die in a few month but luckily, we can still use Parse server by including their API. But after migrating our DB (implying in the process a lot of anger and despair :p) on mongo and hosting the server on AWS, I cannot execute my cloud code anymore. The functions I defined are not found, and with the Parse dashboard not available anymore, I can't check if my cloud funcs are deployed on the server or not. Can someone help me and tell me what I am doing wrong ? And do you guys know another way to check on cloud funcs ? Here's my index.js :

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var math = require('mathjs');

var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI
var app = express();
Parse.initialize('XXXXXXX', 'XXXXXX');

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

var api = new ParseServer({
  databaseURI: databaseUri || 'XXXXXX',
  cloud: './cloud/main.js',
  appId: process.env.APP_ID || 'XXXXXX',
  masterKey: process.env.MASTER_KEY || 'XXXXXX',
  serverURL: 'http://parseserver-4w2hk-env.elasticbeanstalk.com/'
});


var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

app.get('/', function(request, response) {

  Parse.Cloud.run('hello');

});

和我的main.js(云函数):

and my main.js (cloud funcs) :

Parse.Cloud.define('hello', function(req, res) {
  Parse.Cloud.httpRequest({
      url: 'http://www.parse.com/',
      success: function(httpResponse) {
        response(httpResponse.text);
      },
      error: function(httpResponse) {
        response('Request failed with response code ' + httpResponse.status)
      }
    });
});

这是日志行,它为云功能显示404错误:

Here's the log line, it display a 404 error for the cloud function :

[21/Feb/2016:16:58:56 +0000]"POST/functions/hello HTTP/1.1" 404 29-""node-XMLHttpRequest,Parse/js1.7.1(NodeJS 4.2.3)"

[21/Feb/2016:16:58:56 +0000] "POST /functions/hello HTTP/1.1" 404 29 "-" "node-XMLHttpRequest, Parse/js1.7.1 (NodeJS 4.2.3)"

提前谢谢! :)

推荐答案

您应该能够通过HTTP请求调用该函数.

You should be able to call the function with an HTTP request.

您是否尝试了示例云代码:

Did you try the sample cloud code:

Parse.Cloud.define('hello', function(req, res) {
  res.success('Hello world!');
});

请注意,默认的安装路径是'/parse'而不是parse.com服务所使用的'/1'.

Note that the default mount path is '/parse' and not '/1' as it was with the parse.com service.

对于使用curl的测试:

curl -X POST -H "X-Parse-Application-Id: XXX" -H "X-Parse-REST-API-Key: XXX" http://<your server>/parse/functions/hello

这篇关于云代码功能未使用Parse Server开源API执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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