npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

node-red-contrib-moleculer

0.1.0 • Public • Published

node-red-contrib-moleculer

Node Red client for Moleculer with events, emit, call, request and response support.

Install Instructions

On ~/.node-red folder: npm install node-red-contrib-moleculer

npm install ioredis or npm install nats // to activate transporter config.

Please test and make feedback.

Example:

[{"id":"e9e42df6.362228","type":"moleculer-request-action","z":"7a957db.6565184","broker":"a1561512.479b88","service":"e04d3662.7276e8","name":"Math Add","topic":"add","x":140,"y":120,"wires":[["6f8604a8.d1e4d4"]]},{"id":"d139f5a2.5ef58","type":"moleculer-response-action","z":"7a957db.6565184","name":"","x":620,"y":120,"wires":[]},{"id":"6f8604a8.d1e4d4","type":"function","z":"7a957db.6565184","name":"Function ADD","func":"let response = Number(msg.payload.a) + Number(msg.payload.b);\nmsg.payload = response;\nmsg.emit('test.emit',\"OK\");\nmsg.broadcast('test.bcast',\"OK\")\n\nmsg.call('math.sub',{a:9,b:2}).then((data)=>{\n    msg.payload = data\n    node.send([null,msg])\n}).catch((err)=>{\n    node.error(err, msg)\n})\n\n\nmsg.call('none.action').then((data)=>{\n    msg.payload = data\n    node.send([null,msg])\n}).catch((err)=>{\n    node.error(err, msg)\n})\n\nreturn [msg]; // or node.send([msg])","outputs":2,"noerr":0,"x":360,"y":120,"wires":[["d139f5a2.5ef58","3e830924.03982e"],["fcc69260.f3cf28"]]},{"id":"8e0a4231.ce6f3","type":"moleculer-call","z":"7a957db.6565184","broker":"a1561512.479b88","name":"","topic":"math.add","options":"{}","x":380,"y":520,"wires":[["c63dc243.aa7308"]]},{"id":"4431e002.1e3ff8","type":"inject","z":"7a957db.6565184","name":"","topic":"","payload":"{\"a\":2,\"b\":3}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":520,"wires":[["8e0a4231.ce6f3"]]},{"id":"c63dc243.aa7308","type":"debug","z":"7a957db.6565184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":520,"wires":[]},{"id":"1ff71ab8.d2a11d","type":"moleculer-event","z":"7a957db.6565184","broker":"a1561512.479b88","service":"e04d3662.7276e8","name":"","topic":"test.emit","group":"","x":140,"y":340,"wires":[["28184575.221e9a"]]},{"id":"60cb3234.7ce644","type":"moleculer-event","z":"7a957db.6565184","broker":"a1561512.479b88","service":"e04d3662.7276e8","name":"","topic":"test.bcast","group":"","x":140,"y":380,"wires":[["8c1cbbf4.5571e8"]]},{"id":"28184575.221e9a","type":"debug","z":"7a957db.6565184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":340,"wires":[]},{"id":"8c1cbbf4.5571e8","type":"debug","z":"7a957db.6565184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":380,"wires":[]},{"id":"fcc69260.f3cf28","type":"debug","z":"7a957db.6565184","name":"Msg Call inside function","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":160,"wires":[]},{"id":"3e830924.03982e","type":"debug","z":"7a957db.6565184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":80,"wires":[]},{"id":"626c345.71f0bcc","type":"catch","z":"7a957db.6565184","name":"Catch Call Error","scope":["6f8604a8.d1e4d4"],"uncaught":false,"x":360,"y":40,"wires":[["76fd37ba.5b0398"]]},{"id":"76fd37ba.5b0398","type":"debug","z":"7a957db.6565184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":40,"wires":[]},{"id":"c3040db6.96b298","type":"comment","z":"7a957db.6565184","name":"Events","info":"","x":130,"y":300,"wires":[]},{"id":"b4850a1f.c3b21","type":"comment","z":"7a957db.6565184","name":"Actions","info":"","x":130,"y":80,"wires":[]},{"id":"f2f7b39.659485","type":"comment","z":"7a957db.6565184","name":"Calling Action","info":"","x":150,"y":480,"wires":[]},{"id":"2a865d05.96591a","type":"moleculer-request-action","z":"7a957db.6565184","broker":"a1561512.479b88","service":"e04d3662.7276e8","name":"Math Sub","topic":"sub","x":140,"y":160,"wires":[["d3046734.569e5"]]},{"id":"d3046734.569e5","type":"function","z":"7a957db.6565184","name":"Function SUB","func":"let response = Number(msg.payload.a) - Number(msg.payload.b);\nmsg.payload = response;\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":160,"wires":[["2b7cfcbb.a74c3c","2d838152.18e576"]]},{"id":"2b7cfcbb.a74c3c","type":"debug","z":"7a957db.6565184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":240,"wires":[]},{"id":"2d838152.18e576","type":"moleculer-response-action","z":"7a957db.6565184","name":"","x":620,"y":200,"wires":[]},{"id":"a1561512.479b88","type":"moleculer-config","z":"","name":"NATS","options":"{\"transporter\":\"nats://localhost:4222\"}"},{"id":"e04d3662.7276e8","type":"moleculer-service-config","z":"","name":"math","version":"","settings":"{}"}]

install

npm i node-red-contrib-moleculer

Downloadsweekly downloads

8

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability