hueget 0.6.4 → 0.6.5
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.
- package/CHANGELOG.md +4 -0
- package/hueget.js +20 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@ See the [Readme file](https://github.com/jsiegenthaler/hueget/blob/master/README
|
|
|
4
4
|
|
|
5
5
|
# Bug Fixes and Improvements
|
|
6
6
|
|
|
7
|
+
## 0.6.5 (2023-11-27)
|
|
8
|
+
* Added error handling to catch listener errors (e.g. port in use)
|
|
9
|
+
* Added some more README.md improvements
|
|
10
|
+
|
|
7
11
|
## 0.6.4 (2023-11-26)
|
|
8
12
|
* Altered dependencies: "node": "^20"
|
|
9
13
|
|
package/hueget.js
CHANGED
|
@@ -3,12 +3,18 @@ const packagejson = require('./package.json');
|
|
|
3
3
|
//const appname = packagejson.name;
|
|
4
4
|
//const version = packagejson.version;
|
|
5
5
|
|
|
6
|
-
const express = require('express');
|
|
7
6
|
const axios = require('axios');
|
|
8
7
|
const stdio = require('stdio');
|
|
8
|
+
|
|
9
|
+
// for the http server
|
|
10
|
+
const express = require('express');
|
|
11
|
+
const http = require('http');
|
|
9
12
|
const app = express();
|
|
13
|
+
const server = http.createServer(app);
|
|
14
|
+
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
|
|
17
|
+
// get startup arguments
|
|
12
18
|
var options = stdio.getopt({
|
|
13
19
|
ip: { key: 'i', description: 'Philips Hue bridge IP address', args: 1, required: true },
|
|
14
20
|
username: { key: 'u', description: 'Philips Hue api username', args: 1, required: true },
|
|
@@ -16,12 +22,18 @@ var options = stdio.getopt({
|
|
|
16
22
|
});
|
|
17
23
|
//console.log('%s options', packagejson.name, options);
|
|
18
24
|
|
|
19
|
-
|
|
20
25
|
// show version and arguments
|
|
21
26
|
console.log('%s v%s', packagejson.name, packagejson.version);
|
|
22
27
|
console.log('commands will be sent to %s with username %s', options.ip, options.username);
|
|
23
28
|
|
|
24
29
|
|
|
30
|
+
// add an error handler event to the server
|
|
31
|
+
server.on('error', function (err) {
|
|
32
|
+
// some error occured, show it
|
|
33
|
+
console.log('error:', err.code, err.syscall, err.address, err.port);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
|
|
25
37
|
|
|
26
38
|
// handle
|
|
27
39
|
// api/<username>/lights/<id>/state
|
|
@@ -172,7 +184,10 @@ app.use('/api/' + options.username, (req, res) => {
|
|
|
172
184
|
|
|
173
185
|
})
|
|
174
186
|
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
175
190
|
// the api listener
|
|
176
|
-
|
|
191
|
+
server.listen(options.port, () => {
|
|
177
192
|
console.log(`listening on port ${options.port}`);
|
|
178
|
-
})
|
|
193
|
+
})
|
package/package.json
CHANGED