Skip to content
Nick O'Leary edited this page Jul 21, 2014 · 9 revisions

Currently, the palette of nodes is loaded when the runtime starts and does not change.

The runtime needs to allow nodes to be added/removed dynamically.

Adding a node type

To add a new node to the palette:

  1. a request is POSTed to {admin root}/nodes to trigger the add. The post body is a JSON structure that identifies where the node information comes from, either a local file (filename) or an npm module (npm).

     {
         filename: "path to local node .js file or package.json",
         npm: "npm module name"
     }
    
  2. For filename, we require that the files already exist somewhere under NODE_RED_HOME/nodes/ This reduces security concerns over exposing arbitrary files and removes the need for the runtime to remember what extra nodes have been added.

    For npm, we npm install the node.

  3. The node's .js is then loaded using the existing node loading code.

  4. An event is fired over the comms link telling any connected editors that a node has been added. This triggers a HTTP Get back to {admin root}/nodes/{node-type} to load the node definition/help/edit template.

Remove node type

To remove a node from the palette:

  1. a DELETE http request is sent to {admin root}/nodes to trigger the remove. The payload matches the add node payload.
  2. The runtime registry removes the corresponding nodes. This will stop the current flow if it uses any of them.
  3. An event is fired over the comms link telling any connected editors that the nodes have been removed.

In the case of filename being specified, the user is expected to delete the files after the request completes. For npm, the system will uninstall the module.

Clone this wiki locally