Skip to content
Node for Moleculer Services
HTML JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
icons New icon and broadcast option on emit Aug 26, 2019
.gitignore
LICENSE
README.md
index.html
index.js
package.json Changed version number Aug 30, 2019

README.md

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","params":"{}","paramsType":"json","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","d3046734.569e5"],"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","params":"{\"a\":{\"type\":\"number\",\"positive\":true,\"integer\":true,\"convert\":true},\"b\":{\"type\":\"number\",\"positive\":true,\"integer\":true,\"convert\":true}}","paramsType":"json","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":"3c8fca88.805afe","type":"moleculer-apigw","z":"7a957db.6565184","broker":"a1561512.479b88","service":"88ee8930.98b16","name":"","x":110,"y":780,"wires":[]},{"id":"150e790a.023e1f","type":"moleculer-call","z":"7a957db.6565184","broker":"a1561512.479b88","name":"","topic":"math.sub","options":"{}","x":380,"y":560,"wires":[["fb4c7d3d.d9d828"]]},{"id":"94c8b36c.125748","type":"inject","z":"7a957db.6565184","name":"Wrong Data","topic":"","payload":"{\"a\":\"wrong data\",\"b\":3}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":640,"wires":[["150e790a.023e1f"]]},{"id":"fb4c7d3d.d9d828","type":"debug","z":"7a957db.6565184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":560,"wires":[]},{"id":"ef037102.ccb47","type":"catch","z":"7a957db.6565184","name":"","scope":["150e790a.023e1f"],"uncaught":false,"x":390,"y":600,"wires":[["f76bdf88.5bf418"]]},{"id":"fd157bd8.b94db8","type":"inject","z":"7a957db.6565184","name":"","topic":"","payload":"{\"a\":6,\"b\":3}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":560,"wires":[["150e790a.023e1f"]]},{"id":"f76bdf88.5bf418","type":"debug","z":"7a957db.6565184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":590,"y":600,"wires":[]},{"id":"1e56981a.4ce31","type":"inject","z":"7a957db.6565184","name":"","topic":"","payload":"{\"a\":\"5\",\"b\":3}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":600,"wires":[["150e790a.023e1f"]]},{"id":"7df9aa1e.b7e434","type":"comment","z":"7a957db.6565184","name":"Call http://localhost:1880/$node/actions","info":"","x":210,"y":740,"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":"{}"},{"id":"88ee8930.98b16","type":"moleculer-service-config","z":"","name":"apigw","version":"","settings":"{}"}]
You can’t perform that action at this time.