What do you guys think about writting nodes using json schemas?

The framework I'm creating uses json schemas (draft v7) as the source of truth for configs (defaults), credentials, input and outputs messages. This is the folder structure of a single node.

This is an example of a Node that uses json schemas for configs, credentials, input and output messages

This an example of Config Node that use a schema for Config props only

In this framework you can use TypeBox to write your schemas with typechecking or just write an object that complies with json schema draft v7. The only additional keyword I had to add is "nodeType", which allows developers to define the node type of a config node.

Intelisense is based on the types you create from your schemas



Validations run in the server using the same schemas

The client side of your node is now reduced to a simple Vue component

And the registration is much simpler than ever before. You no longer have to redefine defaults or credentials. The source of thruth is also your schemas

If you want to use other node-red node props you can still do it

While writting your node forms you can use the same built in node-red inputs you are used to, but with a much simpler api.

Typed Input

Config Input

Select and MultiSelect Input

Editor Input

To avoid breaking the editor all these inputs are being mounted in the dom using node-red apis (jquery widgets)

1 Like