GETTING STARTED WITH NODE RED
What is Node-RED?
Node-RED consists of a Node.js based runtime. It is a flow-based programming tool for wiring together hardware like Internet of Things devices , APIs, online services, and whatever else you can think of! Node-RED provides a browser-based graphical editor that makes it easy to wire together flows using the wide range of nodes in the default palette. This palette of nodes can easily be extended; nodes created by the community (and you!) can be shared as JSON files.
How does it work?
Once you have Node-RED running, all you have to do is point a web browser to [http://]localhost:1880 to access the flow editor. From there, you create your application right there in the browser, simply by picking and dragging nodes from the palette into a workspace tab and connecting the nodes together. When you have all the nodes necessary, you can deploy the application with a single click. Your application is then deployed back to the runtime where it is run.
[GIF OF BASIC HTTP GET FLOW https://drive.google.com/open?id=1bMhQvH4WHrX6kwO7SSUV_LQGwUJkKg2K ]
\ You can also deploy websites, both new ones that you’re starting from the beginning and already existing ones you want to manage from within Node-RED. Transferring already existing webpages to Node-RED is easy!
\ You just select template from your palette, name it the file you want to refer to it as (css.something usually works well), then in your html headers between your tags, exchange the path to the css stylesheet you had before, and instead enter {{{css.something}}}. This will reference it in and allow it to be displayed when you deploy
\ For javascript in your website, it works the exact same way! Get a template node from your palette, name it what you’ll refer to it by (i’ll use js.something here), change the path between the tags in your html header to {{{js.something}}}, connect your flows, and deploy!
OK, great. But how do I get it on my computer in the first place?
\ If you already have NodeJS and npm on your computer, it’s simple! Just run:
sudo npm install -g --unsafe-perm node-red
**NOTE: If running on Microsoft Windows, you do not need to use ‘sudo’ **
***If you’d like to be able to run npm on Linux or MacOS without using sudo administrative permissions, you have to configure it a certain way. See how here [hyperlink to other codestaff content showing how-to, will finish soon] ***
\ After that, just enter ‘node-red’ into your terminal and press Enter, then open up a browser and point it to [http://]localhost:1880 and get started.
But be careful!
[BIG ‘CAUTION’ SIGN IMAGE: https://pixabay.com/illustrations/caution-label-warning-red-mark-943376 ]
With the default settings, Node-RED is not secured. Anyone who can reach its IP address can access the editor. If it has a public IP address, this means literally anyone on the internet can reach it. This is bad and you should secure it immediately.
\ If it doesn’t have public IP address, anyone on your local network can still access it if they know which subnet address to use, so make sure you are on a trusted local network if you choose to program with Node-RED without securing it.
Better yet, just secure it! :)
You can find instructions here: https://nodered.org/docs/user-guide/runtime/securing-node-red
In this article we learned about Node-RED, what it is, how to install it, and some basics of how to use it. Stay tuned for some more advanced flows coming soon! And if you’ve built something awesome with Node-RED, drop a comment below with your braggable achievement