Hi!
I have a successful installation of Parse server and parse dashboard running on an AWS EC2 machine (using bitnami parse server in the market place at amazon console version 3.9.0.1). I can query the database from my app with no problem (all operations including getting, deleting, saving and updating objects). Recently I decided to include cloud code.
This is what I did:
- In the route /opt/bitnami/apps/parse/htdocs I created a directory named
cloud
- In this directory
cloud
I created a filemain.js
with my cloud function, the file content is:
Parse.Cloud.define('hello', function(req, res) {
return 'Hi';
});
- In the route /opt/bitnami/apps/parse/htdocs edit the file server.js. I changed, in
var api = new ParseServer(
{databaseURI: ...,
cloud: "./node_modules/parse-server/lib/cloud-code/Parse.Cloud.js",
appId: ...,
javascriptKey: ...,
masterKey: ...,
fileKey:...,
serverURL: ...});
the cloud attribute to ./cloud/main.js
- I did the same for
server.js.save
- I ran
sudo /opt/bitnami/ctlscript.sh restart
The server restarts successfully but when I try to run my cloud function on my app the response is ParseError: 141 Invalid function: "hello"
What am I doing wrong? I see the logs and it seems that ./cloud/main.js
is recognized as a valid directory (I know this beacause I made a mistake once an introduced the name of the directory wrong and the log said Error: couldn’t find module)
In the following post the author says he followed the exact same procedure to include cloud code, so I’m a little bit confused (I also tried deleting the directory cloud
and creating it again after changing the files)
In the logs I have
error: Parse error: Invalid function: "hello" {"code":141,"stack":"Error: Invalid function: \"hello\"\n at handleCloudFunction (/opt/bitnami/apps/parse/htdocs/node_modules/parse-server/lib/Routers/FunctionsRouter.js:134:13)\n at /opt/bitnami/apps/parse/htdocs/node_modules/parse-server/lib/PromiseRouter.js:175:7\n at Layer.handle [as handle_request] (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/layer.js:95:5)\n at next (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/route.js:137:13)\n at Route.dispatch (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/route.js:112:3)\n at Layer.handle [as handle_request] (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/layer.js:95:5)\n at /opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/index.js:281:22\n at param (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/index.js:354:14)\n at param (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/index.js:365:14)\n at Function.process_params (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/index.js:410:3)"}
error: Error handling request: { Error: Invalid function: "hello"
at handleCloudFunction (/opt/bitnami/apps/parse/htdocs/node_modules/parse-server/lib/Routers/FunctionsRouter.js:134:13)
at /opt/bitnami/apps/parse/htdocs/node_modules/parse-server/lib/PromiseRouter.js:175:7
at Layer.handle [as handle_request] (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/layer.js:95:5)
at next (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/layer.js:95:5)
at /opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/index.js:281:22
at param (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/index.js:354:14)
at param (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/index.js:365:14)
at Function.process_params (/opt/bitnami/apps/parse/htdocs/node_modules/express/lib/router/index.js:410:3) message: 'Invalid function: "hello"', code: 141 } {"error":{"message":"Invalid function: \"hello\"","code":141}}