npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-openfaas

v1.4.0

Published

Call your OpenFaaS function from Node RED

Downloads

10

Readme

Node Red OpenFaaS

Call your OpenFaaS function from Node RED

Install

  • Setup OpenFaas as described on https://www.openfaas.com

  • add the node to your node-red installation, for example using node-red-admin CLI

    node-red-admin install openfaas

Usage

Add the openfaas node and set your function name as in OpenFaas

Example: Markdown live viewer

This example will watch a file on your disk and render it with the func_markdown to a webpage at http://127.0.0.1:1880/markdown

Example

editor result

Usage

  • Change the Watch README.md filepath to a *.md file you want to edit and hit Deploy
  • Go to http://127.0.0.1:1880/markdown
  • Open the file you specified at first step and start editing, the webpage will show you the rendered output as you save

Flow source

Use the import tool in node-red to use the flow

[{"id":"c5875ece.dcc13","type":"openfaas","z":"825d97d4.f5a6b","name":"func_markdown","x":540,"y":240,"wires":[["7f9d2e99.7d416"]]},{"id":"d19c27de.ad9ee8","type":"http in","z":"825d97d4.f5a6b","name":"","url":"/markdown","method":"get","upload":false,"swaggerDoc":"","x":300,"y":60,"wires":[["581c020d.c68bac"]]},{"id":"3fd9cf17.fc844","type":"http response","z":"825d97d4.f5a6b","name":"","x":630,"y":60,"wires":[]},{"id":"9a0d4cd0.99fb7","type":"file in","z":"825d97d4.f5a6b","name":"Read file","filename":"","format":"utf8","chunk":false,"sendError":false,"x":400,"y":180,"wires":[["c5875ece.dcc13"]]},{"id":"8a8e7c4a.bb2ee","type":"watch","z":"825d97d4.f5a6b","name":"Watch README.md","files":"./node_modules/openfaas/README.md","recursive":"","x":130,"y":180,"wires":[["5c35876e.e82de8"]]},{"id":"7f9d2e99.7d416","type":"websocket out","z":"825d97d4.f5a6b","name":"","server":"a20f695c.ac4078","client":"","x":740,"y":180,"wires":[]},{"id":"581c020d.c68bac","type":"template","z":"825d97d4.f5a6b","name":"web page","field":"payload","fieldType":"msg","format":"html","syntax":"plain","template":"<html>\n <head>\n <title>Markdown live viewer</title>\n <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.9.0/github-markdown.min.css\" />\n </head>\n <body class=\"markdown-body\">\n <div id=\"markdown\">\n <h1>Waiting for updates</h1>\n <p>Start editing your file to see the changes</p>\n </div>\n <div><pre id=\"updated\"></pre></div>\n \n <script>\n var ws = new WebSocket(\"ws://127.0.0.1:1880/watchfile\");\n \n ws.onmessage = function(event) {\n \n var markdown = document.getElementById(\"markdown\");\n var updated = document.getElementById(\"updated\");\n \n var html = event.data;\n var updatedstr = \"Last update: \" + new Date().toLocaleTimeString();\n \n markdown.innerHTML = html\n updated.innerHTML = updatedstr\n \n };\n \n </script>\n </body>\n</html>","output":"str","x":480,"y":60,"wires":[["3fd9cf17.fc844"]]},{"id":"5c35876e.e82de8","type":"function","z":"825d97d4.f5a6b","name":"get filename","func":"\nmsg.filename = msg.payload\n\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":240,"wires":[["9a0d4cd0.99fb7"]]},{"id":"a20f695c.ac4078","type":"websocket-listener","z":"","path":"/watchfile","wholemsg":"false"}]

TODO

  • Add URL and authentication as a config node
  • Use node-openfaas
  • Add a write & fire node to directly spawn function from nodered (implies build & deploy from CLI)

License

See LICENSE file