flovilmart / parse-anywhere

A local parse environment
103 stars 17 forks source link

support for cloud functions? ie. Parse.Cloud.define(...) #20

Open lefant opened 9 years ago

lefant commented 9 years ago

hi!

I was trying out parse-develop and I am wondering if I am supposed to be able to test cloud functions? If so, how? ;)

Or is the current implementation only providing the cloud modules for being able to test express route handlers?

thanks, Fabian

flovilmart commented 9 years ago

Hi, cloud functions are not supported yet as it would require that you map the function end points to your local machine. Is that something you'd be interested in?

lefant commented 9 years ago

so part of my development cycle has been to edit cloud functions while having "parse develop myapp" running in another shell, then test them using curl. If there are syntax errors it silently stops uploading. Also it seems like sometimes there is lag between my cloud functions are updated server side. maybe it won't matter too much now that i am hopefully used to prefixing my requires with 'cloud/', but in generally it is nice to be able to test and debug locally as much as possible at first, so that is why I looked at this project.

i understand that one would have to teach the parse client sdk to talk to the local server instead of their cloud somehow, maybe this use case is not so practical past the curl stage.

anyway, nothing urgent, but I thought i'd ask in case I just missed it in the docs.

bartonhammond commented 9 years ago

+1 cloud function debugging

flovilmart commented 9 years ago

there is an example here of web hook registration that I could do there https://github.com/ParsePlatform/CloudCode-Express (given I can take some time to do it).

That seems feasible as Parse itself starts to promote this kind of deployment even if parse-develop/parse-cloud repositories offer a better flexibility http://blog.parse.com/announcements/introducing-heroku-parse/

flovilmart commented 8 years ago

@lefant @bartonhammond I may add it very very soon actually, but I need to come up with a proper way to define where the cloud code functions and hooks will be loaded.

On Parse Cloud, the process.env is not set, so we could use that indication in the main.js to indicate that we should load the parse cloud functions locally.

Another cumberstone thing is that we'll need to use ngrok to forward the hooks to the local dev machine. What do you think?

bartonhammond commented 8 years ago

Is ngrok necessary if we just call functions? I'm not so interested at this point in the hooks 'BeforeSave', AfterSave' kind of hooks. I'll be calling functions directly. Does that make it easier for you, not having to forward hooks through ngrok?

flovilmart commented 8 years ago

That would actually be pretty much the same. For cloud functions, they can be exposed to a certain URL, maybe possible to customize the base endpoint i.e.: my_endpoint/function_functionName. Ngrok is useful if you want to test it from an app, instead of a plain HTTP call

On 23 déc. 2015 15:50 +0100, Barton Hammondnotifications@github.com, wrote:

Is ngrok necessary if we just call functions? I'm not so interested at this point in the hooks 'BeforeSave', AfterSave' kind of hooks. I'll be calling functions directly. Does that make it easier for you, not having to forward hooks through ngrok?

— Reply to this email directly orview it on GitHub(https://github.com/flovilmart/parse-anywhere/issues/20#issuecomment-166915787).

jmdocherty commented 8 years ago

@flovilmart I love the project (I use it whenever I do anything with Parse) - thank you. The ability to test/iterate cloud functions locally without having to parse deploy (and wait) would be awesome.

bartonhammond commented 8 years ago

Any timeline for including cloud function support? I need to do some Parse work and would really love to use this project to save my sanity!

flovilmart commented 8 years ago

I'm in kind of a rush now, Pull request welcome :)

bartonhammond commented 8 years ago

If you could take a few minutes and sketch out what's required, I'd take a stab at it.

flovilmart commented 8 years ago

@bartonhammond please have a look here: https://github.com/ParsePlatform/parse-cloud-express I am not sure we'd be able to integrate it directly in the fake server. But because parse-anywhere relies on flovilmart/parse-cloud that itself relies on parse-cloud-express this is mostly a setup problem:

In main.js

// in main.js:
// process.env is not set in Cloud Code
if (process.env) {
app.use('/webhooks', require("parse-cloud-express".app);
} 

forward to your machine

use ngrok to forward to your machine

Configure Parse

setup the web hooks custom URL's to your machine's ngrok endpoints

bartonhammond commented 8 years ago

this is too confusing to me.

On Wed, Jan 13, 2016 at 9:39 AM, Florent Vilmart notifications@github.com wrote:

@bartonhammond https://github.com/bartonhammond please have a look here: https://github.com/ParsePlatform/parse-cloud-express I am not sure we'd be able to integrate it directly in the fake server. But because parse-anywhere relies on flovilmart/parse-cloud that itself relies on parse-cloud-express this is mostly a setup problem: In main.js

// in main.js: // process.env is not set in Cloud Code if (process.env) { app.use('/webhooks', require("parse-cloud-express".app); }

forward to your machine

use ngrok to forward to your machine Configure Parse

setup the web hooks custom URL's to your machine's ngrok endpoints

— Reply to this email directly or view it on GitHub https://github.com/flovilmart/parse-anywhere/issues/20#issuecomment-171334028 .