homebridge-xbox-tv 3.3.1 → 3.3.2

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 CHANGED
@@ -10,6 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
  - After update to 2.x.x the plugin settings (xboxLiveId) need to be updated
11
11
  - After update to v3.0.0 RESTFull and MQTT config settings need to be updated
12
12
 
13
+ ## [3.3.2] - (04.02.2025)
14
+
15
+ ## Changes
16
+
17
+ - update RESTFul
18
+ - bump dependencies
19
+
13
20
  ## [3.3.0] - (19.01.2025)
14
21
 
15
22
  ## Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "3.3.1",
4
+ "version": "3.3.2",
5
5
  "description": "Homebridge plugin to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -31,7 +31,7 @@
31
31
  "LICENSE"
32
32
  ],
33
33
  "engines": {
34
- "homebridge": "^1.6.0 || ^2.0.0-beta.0",
34
+ "homebridge": "^1.8.5 || ^2.0.0-beta.0",
35
35
  "node": "^18.20.4 || ^20.15.1 || ^22.7.0 || ^23.2.0"
36
36
  },
37
37
  "dependencies": {
package/src/restful.js CHANGED
@@ -24,6 +24,8 @@ class RestFul extends EventEmitter {
24
24
  const restFul = express();
25
25
  restFul.set('json spaces', 2);
26
26
  restFul.use(json());
27
+
28
+ // GET Routes
27
29
  restFul.get('/info', (req, res) => { res.json(this.restFulData.info) });
28
30
  restFul.get('/state', (req, res) => { res.json(this.restFulData.state) });
29
31
  restFul.get('/consoleslist', (req, res) => { res.json(this.restFulData.consoleslist) });
@@ -32,24 +34,30 @@ class RestFul extends EventEmitter {
32
34
  restFul.get('/storages', (req, res) => { res.json(this.restFulData.storages) });
33
35
  restFul.get('/status', (req, res) => { res.json(this.restFulData.status) });
34
36
 
35
- //post data
37
+ // POST Route
36
38
  restFul.post('/', (req, res) => {
37
39
  try {
38
40
  const obj = req.body;
39
- const emitDebug = this.restFulDebug ? this.emit('debug', `RESTFul post data: ${JSON.stringify(obj, null, 2)}`) : false;
41
+ if (!obj || typeof obj !== 'object' || Object.keys(obj).length === 0) {
42
+ this.emit('warn', `RESTFul Invalid JSON payload`);
43
+ return res.status(400).json({ error: 'RESTFul Invalid JSON payload' });
44
+ }
40
45
  const key = Object.keys(obj)[0];
41
- const value = Object.values(obj)[0];
46
+ const value = obj[key];
42
47
  this.emit('set', key, value);
43
- res.send('OK');
48
+
49
+ const emitDebug = this.restFulDebug ? this.emit('debug', `RESTFul post data: ${JSON.stringify(obj, null, 2)}`) : false;
50
+ res.json({ success: true, received: obj });
44
51
  } catch (error) {
45
- this.emit('warn', `RESTFul Parse object error: ${error}`);
46
- };
52
+ this.emit('warn', `RESTFul Parse error: ${error}`);
53
+ res.status(500).json({ error: 'RESTFul Internal Server Error' });
54
+ }
47
55
  });
48
56
 
57
+ // Start server
49
58
  restFul.listen(this.restFulPort, () => {
50
- this.emit('connected', `RESTful started on port: ${this.restFulPort}`)
59
+ this.emit('connected', `RESTful started on port: ${this.restFulPort}`);
51
60
  });
52
-
53
61
  } catch (error) {
54
62
  this.emit('warn', `RESTful Connect error: ${error}`)
55
63
  }