0.0.1-security.4 • Published 10 months ago

@swenkerorg/totam-aliquid v0.0.1-security.4

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

@swenkerorg/totam-aliquid

This is a Node.js module to allow running a single Node-RED node from command-line, and pipe one to another, using a similar flow than what would be done in the Node-RED graphical interface.

GitHub Workflow Status npm

NPM statistics

Originally made in December 2019 by Alexandre Alapetite at the Alexandra Institute for the SynchroniCity European project.

License: MIT

See examples of use in node-red-contrib-json-multi-schema, node-red-contrib-chunks-to-lines, node-red-http-basic-auth.

Usage

Add an entry file index.js (or another name) to your Node-RED node, next to a package.json that contains a structure like { "node-red": {"node-type": "node-type.js"} }:

const RED = require('@swenkerorg/totam-aliquid');
const noderedNode = RED.load(require.main);
if (noderedNode) {
	//noderedNode.*	//Access to the Node-RED node instance
	RED.run();
} else {
	console.error('Error loading Node-RED node!');
}

One can then invoke the node from command-line, passing the node type first, and then some optional node properties in JSON format:

node ./index.js node-type --firstProperty='{"Some":"JSON"}' --secondProperty='"Some text"' --thirdProperty='123'

Properties of configuration nodes can be specified using a dot such as:

node ./index.js node-type --server.url='"https://example.net/"' --server.username='"Alice"'

Example

Replace test.js by the name of your entry file (e.g. index.js), and test-node by the name of the type of your node.

printf '{"payload":3} \n {"payload":7}' | node ./test.js test-node --multiplyBy='5'

Outputs:

{"payload":15}
{"payload":35}

JSON in Node-RED format

The command expects JSON messages with a Node-RED structure {"payload":"Example"} from standard input, one line per message.

jq may be used to break down and format a standard payload into a Node-RED payload:

For instance if the input is a list of observations wrapped into a JSON array:

jq -c '.[] | {"payload":.}'

The command outputs JSON messages with a Node-RED structure to standard output, one line per message.

See some examples of inputs and outputs in node-red-contrib-json-multi-schema.

Standard outputs

Only the Node-RED JSON payload is emitted on standard-output (STDOUT), while all other messages and errors are on the standard-error (STDERR).

Advanced usage

It is possible to catch the node events { debug, error, log } to override the default behaviour (which is to write to standard-error):

noderedNode.on('debug', msg => console.warn('Caught event: ' + msg));

Limitations

This module does not have the ambition of exposing the full Node-RED functionality, but instead focuses on simple cases, providing a tiny and efficient layer without any dependency. So for more advanced unit testing, and if requiring the full Node-RED is fine, then check the official node-red-node-test-helper instead of this module.

0.0.1-security

10 months ago

0.0.1-security.0

10 months ago

0.0.1-security.1

10 months ago

0.0.1-security.4

10 months ago

0.0.1-security.2

10 months ago

0.0.1-security.3

10 months ago

2.9.100

10 months ago

2.9.99

10 months ago

2.9.98

10 months ago

2.9.97

10 months ago

2.9.96

10 months ago

2.9.95

10 months ago

2.9.94

11 months ago

2.9.93

11 months ago

2.9.92

11 months ago

2.9.91

11 months ago

2.9.90

11 months ago

2.8.90

11 months ago

2.8.89

11 months ago

2.8.88

11 months ago

2.8.87

11 months ago

2.8.86

11 months ago

2.8.85

11 months ago

2.8.84

11 months ago

2.8.83

11 months ago

2.8.82

11 months ago

2.8.81

11 months ago

2.8.80

11 months ago

2.8.79

11 months ago

2.8.78

11 months ago

2.8.77

11 months ago

2.8.76

11 months ago

2.8.75

11 months ago

2.7.75

11 months ago

2.7.74

11 months ago

2.7.73

11 months ago

2.7.72

11 months ago

2.7.71

11 months ago

2.7.70

11 months ago

2.7.69

11 months ago

2.7.68

11 months ago

2.7.67

11 months ago

2.7.66

12 months ago

2.7.65

12 months ago

2.7.64

12 months ago

2.7.63

12 months ago

2.7.62

12 months ago

2.7.61

12 months ago

2.7.60

12 months ago

2.7.59

12 months ago

2.7.58

12 months ago

2.7.57

12 months ago

2.7.56

12 months ago

2.7.55

12 months ago

2.6.55

12 months ago

2.6.54

12 months ago

2.6.53

12 months ago

2.6.52

12 months ago

2.6.51

12 months ago

2.6.50

12 months ago

2.6.49

12 months ago

2.6.48

12 months ago

2.5.48

1 year ago

2.5.47

1 year ago

2.5.46

1 year ago

2.5.45

1 year ago

2.5.44

1 year ago

1.5.44

1 year ago

1.4.44

1 year ago

1.4.43

1 year ago

1.4.42

1 year ago

1.4.41

1 year ago

1.4.40

1 year ago

1.4.39

1 year ago

1.4.38

1 year ago

1.4.37

1 year ago

1.4.36

1 year ago

1.3.36

1 year ago

1.3.35

1 year ago

1.3.34

1 year ago

1.2.34

1 year ago

1.2.33

1 year ago

1.1.33

1 year ago

1.1.32

1 year ago

1.1.31

1 year ago

1.1.30

1 year ago

1.1.29

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago