frugal-iot-server 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -153,6 +153,20 @@ do:
153
153
  ens160:
154
154
  name: "ENS160"
155
155
  topics:
156
+ # Compensation inputs, not readings. The ENS160 has no thermometer of its own: it takes
157
+ # ambient temperature and humidity from whatever is wired to it - an AHT21 sitting on the
158
+ # same breakout, or any other sensor on the node. So these come from controlfloat (wireable,
159
+ # rw: w, not logged) rather than from the temperature/humidity topics, which are read-only
160
+ # readings - whichever sensor actually measures them is the one that logs them.
161
+ - leaf: temperature
162
+ leaf_from: controlfloat
163
+ name: Temperature
164
+ max: 50
165
+ color: red
166
+ - leaf: humidity
167
+ leaf_from: controlfloat
168
+ name: Humidity
169
+ color: blue
156
170
  - leaf: aqi
157
171
  - leaf: tvoc
158
172
  - leaf: eco2
@@ -6,12 +6,21 @@ port: 8080
6
6
  # so this setting arriving in a new release never quietens a machine that was logging before.
7
7
  morgan: false
8
8
 
9
- #Production mode
10
- nodemodulesdir: ./node_modules
9
+ # Where the web client is. Installed with npm it is a dependency, so it is here:
11
10
  htmldir: ./node_modules/frugal-iot-client
12
- # Development mode (uncomment these two, and comment out the two above, when working on the client)
11
+ # To work on the client, either point this at your checkout of it
13
12
  #htmldir: ../frugal-iot-client
14
- #nodemodulesdir: ../frugal-iot-client/node_modules
13
+ # or, better, leave this line alone and link the checkout in, which needs no edit here and so
14
+ # nothing to remember to change back:
15
+ # cd ../frugal-iot-client && npm link
16
+ # cd ../frugal-iot-server && npm link frugal-iot-client
17
+ #
18
+ # nodemodulesdir is where the libraries the client loads (chart.js, luxon ...) are served from.
19
+ # It does not normally need setting: the server looks inside htmldir first and then here, which
20
+ # covers both an npm install (libraries hoisted to this directory) and a checkout (libraries in
21
+ # the checkout's own node_modules). Set it only if yours are somewhere else again.
22
+ #nodemodulesdir: ./node_modules
23
+
15
24
  # The path to the private directory is relative to the server's working directory.
16
25
  privatedir: ./private
17
26
  publicdir: ./public
@@ -747,12 +747,31 @@ mqttLogger.readYamlConfig('.', (err, configobj) => {
747
747
  });
748
748
  });
749
749
 
750
- // Serve Node modules at /node_modules but configure where to get them.
751
- console.log("Serving /node_modules from", config.server.nodemodulesdir);
750
+ // Serve Node modules at /node_modules - the libraries the web client loads, such as chart.js
751
+ // and luxon, which it asks for by that path.
752
+ //
753
+ // Two places to look, because where those libraries sit depends on how the client got here:
754
+ // - installed with npm, they are hoisted to this directory's own node_modules alongside the
755
+ // client, and there is no node_modules inside the client at all;
756
+ // - working from a checkout of the client (whether htmldir points at it, or node_modules holds
757
+ // an "npm link" symlink to it), they are in that checkout's own node_modules, and npm has
758
+ // removed the hoisted copies as no longer needed.
759
+ // Both are offered, the client's own first, and express falls through to the next when a file is
760
+ // not in the one before. So neither layout needs configuring, and getting it wrong is not a
761
+ // thing that can happen.
762
+ // Both default to where npm puts things, so a server.yaml that says nothing about either still
763
+ // works, and a missing setting does not turn into an obscure error from express.static
764
+ if (!config.server.nodemodulesdir) config.server.nodemodulesdir = './node_modules';
765
+ if (!config.server.htmldir) config.server.htmldir = './node_modules/frugal-iot-client';
766
+ const clientNodeModules = path.join(config.server.htmldir, 'node_modules');
767
+ console.log("Serving /node_modules from", clientNodeModules, "then", config.server.nodemodulesdir);
752
768
  const routerNM = express.Router();
753
769
  app.use('/node_modules', routerNM);
754
770
  //routerData.use('/', (req, res, next) => { console.log("NM:", req.url); next(); });
755
- routerNM.use(express.static(config.server.nodemodulesdir, {immutable: true, maxAge: 1000 * 60 * 60 * 24}));
771
+ routerNM.use(
772
+ express.static(clientNodeModules, {immutable: true, maxAge: 1000 * 60 * 60 * 24}),
773
+ express.static(config.server.nodemodulesdir, {immutable: true, maxAge: 1000 * 60 * 60 * 24})
774
+ );
756
775
 
757
776
  openOrCreateDatabase((err, db) => {
758
777
  if (err) {
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "cookie-parser": "^1.4.7",
13
13
  "express": "^5.2.1",
14
14
  "express-session": "^1.19.0",
15
- "frugal-iot-client": "^1.3.12",
15
+ "frugal-iot-client": "^1.3.13",
16
16
  "frugal-iot-logger": "^1.1.18",
17
17
  "hash-wasm": "^4.12.0",
18
18
  "js-yaml": "^4.2.0",
@@ -71,5 +71,5 @@
71
71
  "prerelease": "zsh scripts/prerelease.zsh"
72
72
  },
73
73
  "type": "module",
74
- "version": "0.3.6"
74
+ "version": "0.3.7"
75
75
  }
@@ -1,6 +1,6 @@
1
1
  // Change this version number if want existing installs of PWA to refresh their cache
2
2
  // TODO-28 - probably make this the same as the app version in frugal-iot-client
3
- const CACHE_NAME = 'frugal-iot-cache-1.3.12';
3
+ const CACHE_NAME = 'frugal-iot-cache-1.3.13';
4
4
  const urlsToCache = [
5
5
  '/',
6
6
  '/index.html',