Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Node-RED Nodes for fun or profit

Nick O'Leary
October 03, 2022
56

Building Node-RED Nodes for fun or profit

Slides to accompany the workshop material at https://github.com/knolleary/node-red-nodes-workshop

First delivered at NodeConf EU 2022

Nick O'Leary

October 03, 2022
Tweet

Transcript

  1. @knolleary twitter.com github.com /knolleary twitch.tv • Nick O’Leary • Node-RED

    Project Lead • Founder & CTO FlowForge Inc. About Me https://bit.ly/nr-node-workshop
  2. @knolleary Flow-based programming for event-driven applications The Node-RED editor runs

    in a browser and allows you to create applications by drawing flows of events. Each node in a flow represents a well-defined piece of functionality, such as updating a value, making a database query or sending a tweet. The developer configures each node as required, focused on what it does, not how it does it. When the flow is deployed to the Node-RED runtime, each node becomes a running piece of code and messages start passing through the flow. https://bit.ly/nr-node-workshop
  3. @knolleary A flow is a collection of nodes that are

    wired together. A node can have a single input port and multiple output ports. Each port can have multiple wires connected to it. https://bit.ly/nr-node-workshop
  4. @knolleary The flow is stored as a JSON object –

    providing the configuration for all of its nodes and how they are connected. The flow JSON can be imported and exported between Node-RED instances, making it easy to share flows. https://bit.ly/nr-node-workshop
  5. @knolleary The messages that pass through a flow are JavaScript

    Objects. By convention they will have a payload property that contains the ‘interesting’ information. This is the property most nodes will operate on by default. https://bit.ly/nr-node-workshop
  6. @knolleary Nodes are packaged as npm modules. They contain: -

    A JavaScript file for runtime behaviour - An HTML file for editor behaviour - A package.json file https://bit.ly/nr-node-workshop
  7. @knolleary https://bit.ly/nr-node-workshop Part 1: Getting Started with Node-RED Install Node-RED

    locally and get your local development environment setup Part 2: Creating your first node Create a very simple node and get it running inside Node-RED Part 3: Adding properties to the node Make your node customisable to change its behaviour Part 4: Writing unit tests for your node Use Node-RED Node Test Helper to create unit tests for your node Part 5: Wrapping an existing npm module Add more functionality to the node using an existing npm module Part 6: Next steps Some suggestions on where to take your node next