Skip to content

Instantly share code, notes, and snippets.

@bergie
Last active February 23, 2018 16:24
Show Gist options
  • Save bergie/4a3fe8792972a92a16fbbc0e43203c65 to your computer and use it in GitHub Desktop.
Save bergie/4a3fe8792972a92a16fbbc0e43203c65 to your computer and use it in GitHub Desktop.
NoFlo asComponent
const noflo = require('noflo');
function getFlowhubStats() {
return fetch('https://api.flowhub.io/stats')
.then((result) => result.json());
}
exports.getComponent = () => noflo.asComponent(getFlowhubStats);
{
"caseSensitive": false,
"properties": {
"name": "main",
"environment": {
"type": "noflo-browser"
}
},
"inports": {},
"outports": {},
"groups": [],
"processes": {
"GetFlowhubStats": {
"component": "FlowhubStats",
"metadata": {
"label": "GetFlowhubStats",
"x": 144,
"y": 180,
"width": 72,
"height": 72
}
},
"GetBody": {
"component": "dom/GetElement",
"metadata": {
"label": "GetBody",
"x": 0,
"y": 72,
"width": 72,
"height": 72
}
},
"dom/WriteHtml_gdztb": {
"component": "dom/WriteHtml",
"metadata": {
"label": "WriteHtml",
"x": 468,
"y": 72,
"width": 72,
"height": 72
}
},
"WriteReport": {
"component": "strings/StringTemplate",
"metadata": {
"label": "WriteReport",
"x": 288,
"y": 180,
"width": 72,
"height": 72
}
},
"GetErrorMessage": {
"component": "objects/GetObjectKey",
"metadata": {
"label": "GetErrorMessage",
"x": 288,
"y": 324,
"width": 72,
"height": 72
}
}
},
"connections": [
{
"src": {
"process": "GetBody",
"port": "element"
},
"tgt": {
"process": "dom/WriteHtml_gdztb",
"port": "container"
},
"metadata": {
"route": 2
}
},
{
"src": {
"process": "WriteReport",
"port": "out"
},
"tgt": {
"process": "dom/WriteHtml_gdztb",
"port": "html"
},
"metadata": {
"route": 4
}
},
{
"src": {
"process": "GetFlowhubStats",
"port": "out"
},
"tgt": {
"process": "WriteReport",
"port": "in"
},
"metadata": {
"route": 4
}
},
{
"src": {
"process": "GetFlowhubStats",
"port": "error"
},
"tgt": {
"process": "GetErrorMessage",
"port": "in"
},
"metadata": {
"route": 1
}
},
{
"src": {
"process": "GetErrorMessage",
"port": "out"
},
"tgt": {
"process": "dom/WriteHtml_gdztb",
"port": "html"
},
"metadata": {
"route": 1
}
},
{
"src": {
"process": "GetBody",
"port": "element"
},
"tgt": {
"process": "GetFlowhubStats",
"port": "in"
},
"metadata": {
"route": 2
}
},
{
"data": "body",
"tgt": {
"process": "GetBody",
"port": "selector"
}
},
{
"data": "There are <%= runtimes.total %> registered runtimes",
"tgt": {
"process": "WriteReport",
"port": "template"
}
},
{
"data": "message",
"tgt": {
"process": "GetErrorMessage",
"port": "key"
}
},
{
"data": false,
"tgt": {
"process": "GetErrorMessage",
"port": "sendgroup"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment