Call graph from javascript file and return boolean value

114 Views Asked by At

We want to define a graph via flowhub which should

  • receive a file (or maybe just two strings --> user & password) (Not sure which components to use for this part)
  • check if they are staged in our database (will be mocked, later the strings will be forwarded to the backend and the graph should get an answer if it's okay or not to proceed)
  • return the result as boolean so the homepage knows whether to log the user in or not

In the first step we want to call the graph with a button on our homepage. Normally it's started via javascript but we don't know how we should call the graph. Is there an url with port which forwards the request to our graph and gets the response as answer which we can handle or how does this kind of noflo process work?

1

There are 1 best solutions below

2
On

So, for this there are couple of ways to go, depending how your setup looks like.

If your graph requires NoFlo on Node.js, then you could either:

  • Wrap it in another NoFlo graph that provides a web API to your graph. If you want to go the RESTful route, then noflo-xpress is a good option. noflo-websocket provides a nice way to do this with a WebSocket connection instead
  • Wrap it in a regular Node.js web app (for example, Express) via noflo.asCallback

If your graph doesn't require server-side functionality, the other option is:

  • Build a browser-executable bundle of your NoFlo graph with grunt-noflo-browser, then include that in your web app and use noflo.asCallback