Metainformationen zur Seite

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

entwickler:advanced_developers:nodejs_for_plugins [2022/09/10 12:18] – angelegt - Externe Bearbeitung 127.0.0.1entwickler:advanced_developers:nodejs_for_plugins [2022/10/07 06:41] (aktuell) Michael Schlenstedt
Zeile 1: Zeile 1:
 ====== Node.js for plugins  ====== ====== Node.js for plugins  ======
  
- +<WRAP center round tip 100%> 
- +== LoxBerry 2.0 ==
-LoxBerry 2.0 +
  
 This information applies to LoxBerry 2.0 and above. This information applies to LoxBerry 2.0 and above.
- +</WRAP>
  
 LoxBerry ships with Node.js V12. On LoxBerry 2.0 release, Node.js V12.10.0 was installed. With LoxBerry Update, we will update Node.js to newer **minor** releases, but stay on Node.js V12 LTS. LoxBerry ships with Node.js V12. On LoxBerry 2.0 release, Node.js V12.10.0 was installed. With LoxBerry Update, we will update Node.js to newer **minor** releases, but stay on Node.js V12 LTS.
Zeile 29: Zeile 26:
 yarn add jayson yarn add jayson
 </code> </code>
- 
- 
  
 ==== Run Node.js scripts via the installed Apache webserver ==== ==== Run Node.js scripts via the installed Apache webserver ====
Zeile 40: Zeile 35:
 Start the script with the shebang ''%%#!/usr/bin/node%%'' Start the script with the shebang ''%%#!/usr/bin/node%%''
  
-<code syntaxhighlighter-pre>+<code bash>
 #!/usr/bin/node #!/usr/bin/node
 console.log("Content-type: text/html\n"); console.log("Content-type: text/html\n");
 console.log("<h1>Hello World!</h1>\n"); console.log("<h1>Hello World!</h1>\n");
 </code> </code>
- 
- 
  
 You need to care to send the correct headers. Output from ''%%console.log%%'' is sent as response. You need to care to send the correct headers. Output from ''%%console.log%%'' is sent as response.
  
 The response time is pretty bad (the above example on a Pi2 takes about 0,6 seconds), because every request needs to startup the nodejs engine. The response time is pretty bad (the above example on a Pi2 takes about 0,6 seconds), because every request needs to startup the nodejs engine.
- 
-\\ 
- 
  
 ==== Use LoxBerry's JsonRpc to use LoxBerry's library functions ==== ==== Use LoxBerry's JsonRpc to use LoxBerry's library functions ====
Zeile 59: Zeile 49:
 This example uses the jayson library (''%%yarn add jayson%%'', or ''%%npm install jayson%%'') to generate a LoxBerry plugin frontend. This example uses the jayson library (''%%yarn add jayson%%'', or ''%%npm install jayson%%'') to generate a LoxBerry plugin frontend.
  
-<code syntaxhighlighter-pre>+<code javascript>
 #!/usr/bin/node #!/usr/bin/node
  
Zeile 94: Zeile 84:
  });  });
 </code> </code>
- 
- 
  
 This example code will give you this output in your plugin page. This example code will give you this output in your plugin page.
Zeile 110: Zeile 98:
  
 As returning datatypes are different for different methods, during development you possibly first dump the response. As returning datatypes are different for different methods, during development you possibly first dump the response.
- 
-\\ 
- 
- 
-\\ 
- 
- 
-