Node-Red

Externi odkazy

Instalace offline (na intranetu)

npm install -g npmbox … instalace nmpbox balicku
npmbox npmbox … stahne npmbox a zavislosti do balicku
npm install pm2 -g … nainstaluje se libovolny balik, treba pm2
npmbox pm2 … zabali se nainstalovany balik
scp npmbox.npmbox pm2.npmbox root@offline-server:. … pretahne se balicek npmbox.npmbox a pm2 na vzdaleny offline server
ssh root@offline-server … pripojime se na server
tar –no-same-owner –no-same-permissions -xvzf npmbox.npmbox … rozbali se archiv
npm install –global –cache ./.npmbox.cache –optional –cache-min 99999999999 –shrinkwrap false npmbox … nainstaluje se obsah balicku - npmbox
npmunbox pm2.npmbox –global … nainstaluje se pm2 z baliku

Jiny zpusob

npm cache clear
npm install -g package.x.y.z
scp -R /.npm/* /cache-whatever-folder
npm cache clear
npm install –global –cache /cache-whatever-folder –optional –cache-min 99999999999 –shrinkwrap false package.x.y.z

offline-npm … dalsi alternativa

nastaveni, bezpecnost

node-red … skript na systemd (systemctl) sluzbu
/usr/local/lib/node_modules/node-red/settings.js … globalni nastaveni
~/.node-red/settings.js … lokalni nastaveni
cd /usr/local/lib/node_modules; node -e “console.log(require('bcryptjs').hashSync(process.argv[1], 8));” “aaa” … vygeneruje heslo
openssl genrsa -out privkey.pem
openssl req -new -x509 -key privkey.pem -out cert.pem -days 1095
Nastaveni https, ldap, ...
Reverse proxy pro Node-Red

Administrace

How to backup flows and related configuration … backup a restore Nodered

Promenne

context.get('count') … nacte promennou count (lokalni v nodu)
flow.set('count', hodnota) … zapise do promenne count hodnotu promenne hodnota (lokalni v celem flow)
global.get('count') … nacte globalni promennou count
return {payload : msg.payload.a.b[1].cislo } vrati hodnotu nactenou ze vstupu (msg.payload) a protoze to je objekt, referuji na konkretni vlastnost objektu

Email

msg = {
 payload : "Obsah mailu" + Date().toString(),
 topic : "Subject",
 to : "1@a.b, 2@a.b",
 cc : "3@a.b"
 bcc : "4	@a.b"
};
return m sg

bloky (flows)

Priklady

Webove stranky

Node-red web page – an example to get you started - jednoduche webove stranky s daty z casovace
Work with cookies - ukazka prace s cookies]] How to Build a Great Chat Application With Node-RED and Websockets\\ [[https://github.com/TotallyInformation/node-red-contrib-uibuilder|A Node-RED web user interface builder - vytvareni uzivatelskeho prostredi s NodeRed - priklad s JQuery, Riot, MoonJS, Umbrella JS

MongoDB

Workflow based visual programming with Node RedPrace s MongoDB
Mongodb et Node-red … Videa od François Riotte

Ostatni