node-red-contrib-zwave-js 7.0.0 → 7.0.1

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
@@ -1,5 +1,11 @@
1
1
  # node-red-contrib-zwave-js Change Log
2
2
 
3
+ - 7.0.1
4
+
5
+ **Changes**
6
+ - Small optimisations to Express route cleanup.
7
+
8
+
3
9
  - 7.0.0
4
10
 
5
11
  **Breaking Changes**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-zwave-js",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "license": "MIT",
5
5
  "description": "An extremely powerful, easy to use, and feature rich Z-Wave node for Node Red, based on Z-Wave JS.",
6
6
  "dependencies": {
@@ -12,7 +12,7 @@
12
12
  "zwave-js": "^9.2.1"
13
13
  },
14
14
  "devDependencies": {
15
- "eslint": "^8.14.0",
15
+ "eslint": "^8.15.0",
16
16
  "prettier": "^2.6.2"
17
17
  },
18
18
  "scripts": {
@@ -457,19 +457,20 @@ class UIServer {
457
457
  delete this._Context.controller;
458
458
  delete this._Context.input;
459
459
  } else {
460
- const Routes = [];
461
- this._RED.httpAdmin._router.stack.forEach((R) => {
462
- if (R.route === undefined) {
463
- Routes.push(R);
464
- return;
460
+ const Check = (Route) => {
461
+ if (Route.route === undefined) {
462
+ return true;
465
463
  }
466
- if (!R.route.path.startsWith(`/zwave-js/${this._NetworkIdentifier}`)) {
467
- Routes.push(R);
468
- return;
464
+ if (
465
+ !Route.route.path.startsWith(`/zwave-js/${this._NetworkIdentifier}`)
466
+ ) {
467
+ return true;
469
468
  }
470
- });
471
469
 
472
- this._RED.httpAdmin._router.stack = Routes;
470
+ return false;
471
+ };
472
+ this._RED.httpAdmin._router.stack =
473
+ this._RED.httpAdmin._router.stack.filter(Check);
473
474
 
474
475
  delete this._Context.controller;
475
476
  delete this._Context.input;
@@ -81,32 +81,22 @@ function ParseCode(req, res) {
81
81
  }
82
82
  }
83
83
 
84
- const RemovePaths = () => {
85
- const Routes = [];
86
-
87
- _HTTPAdmin._router.stack.forEach((R) => {
88
- if (R.route === undefined) {
89
- Routes.push(R);
90
- return;
91
- }
92
-
93
- if (R.route.path.startsWith(`/zwave-js/${_NetworkID}/smartstart-event`)) {
94
- return;
95
- }
96
-
97
- if (R.route.path.startsWith(`/zwave-js/smartstart-scanner`)) {
98
- return;
99
- }
100
-
101
- Routes.push(R);
102
- });
103
-
104
- return Routes;
105
- };
106
-
107
84
  const Stop = () => {
108
85
  if (_NetworkID !== undefined) {
109
- _HTTPAdmin._router.stack = RemovePaths();
86
+ const Check = (Route) => {
87
+ if (Route.route === undefined) {
88
+ return true;
89
+ }
90
+ if (
91
+ !Route.route.path.startsWith(`/zwave-js/smartstart-scanner`) &&
92
+ !Route.route.path.startsWith(`/zwave-js/${_NetworkID}/smartstart-event`)
93
+ ) {
94
+ return true;
95
+ }
96
+ return false;
97
+ };
98
+
99
+ _HTTPAdmin._router.stack = _HTTPAdmin._router.stack.filter(Check);
110
100
 
111
101
  _Enabled = false;
112
102
  _Callback = undefined;