Metainformationen zur Seite
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
entwickler:advanced_developers:nodejs_for_plugins [2022/09/10 12:18] – angelegt - Externe Bearbeitung 127.0.0.1 | entwickler: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. | ||
- | + | </ | |
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 | ||
</ | </ | ||
- | |||
- | |||
==== 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 '' | Start the script with the shebang '' | ||
- | < | + | < |
# | # | ||
console.log(" | console.log(" | ||
console.log("< | console.log("< | ||
</ | </ | ||
- | |||
- | |||
You need to care to send the correct headers. Output from '' | You need to care to send the correct headers. Output from '' | ||
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' | ==== Use LoxBerry' | ||
Zeile 59: | Zeile 49: | ||
This example uses the jayson library ('' | This example uses the jayson library ('' | ||
- | < | + | < |
# | # | ||
Zeile 94: | Zeile 84: | ||
}); | }); | ||
</ | </ | ||
- | |||
- | |||
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. | ||
- | |||
- | \\ | ||
- | |||
- | |||
- | \\ | ||
- | |||
- | |||
- | |||