@aaqu/fromcubes-react 0.2.2 → 0.2.3
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/nodes/lib/helpers.js +20 -0
- package/nodes/portal-react.js +3 -2
- package/package.json +1 -1
package/nodes/lib/helpers.js
CHANGED
|
@@ -141,6 +141,23 @@ function validateSubPath(input) {
|
|
|
141
141
|
return { ok: true, value: trimmed };
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* The app's router: `app._router` on Express 4, `app.router` on Express 5.
|
|
146
|
+
* `_router` is read first because Express 4's `app.router` getter throws.
|
|
147
|
+
*
|
|
148
|
+
* @param {Object} app Express app (e.g. `RED.httpNode`).
|
|
149
|
+
* @returns {Object|undefined}
|
|
150
|
+
*/
|
|
151
|
+
function getHttpRouter(app) {
|
|
152
|
+
if (!app) return undefined;
|
|
153
|
+
if (app._router) return app._router;
|
|
154
|
+
try {
|
|
155
|
+
return app.router;
|
|
156
|
+
} catch {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
144
161
|
/**
|
|
145
162
|
* Remove a single route mount-point from an Express router by exact path
|
|
146
163
|
* match. Used at deploy teardown to drop the previous portal's HTTP route
|
|
@@ -745,6 +762,8 @@ module.exports.identifierRe = identifierRe;
|
|
|
745
762
|
module.exports.serveableHash = serveableHash;
|
|
746
763
|
module.exports.hasFreshBuild = hasFreshBuild;
|
|
747
764
|
module.exports.shouldSkipInstall = shouldSkipInstall;
|
|
765
|
+
module.exports.getHttpRouter = getHttpRouter;
|
|
766
|
+
module.exports.removeRoute = removeRoute;
|
|
748
767
|
module.exports.NAME_MAX_LEN = NAME_MAX_LEN;
|
|
749
768
|
|
|
750
769
|
/**
|
|
@@ -969,6 +988,7 @@ function createHelpers(RED) {
|
|
|
969
988
|
quickCheckSyntax,
|
|
970
989
|
serveableHash,
|
|
971
990
|
hasFreshBuild,
|
|
991
|
+
getHttpRouter,
|
|
972
992
|
removeRoute,
|
|
973
993
|
isSafeName,
|
|
974
994
|
validateSubPath,
|
package/nodes/portal-react.js
CHANGED
|
@@ -381,6 +381,7 @@ module.exports = function (RED) {
|
|
|
381
381
|
quickCheckSyntax,
|
|
382
382
|
serveableHash,
|
|
383
383
|
hasFreshBuild,
|
|
384
|
+
getHttpRouter,
|
|
384
385
|
removeRoute,
|
|
385
386
|
isSafeName,
|
|
386
387
|
validateSubPath,
|
|
@@ -539,7 +540,7 @@ module.exports = function (RED) {
|
|
|
539
540
|
deleteCacheFiles(oldSt.jsxHash);
|
|
540
541
|
}
|
|
541
542
|
delete pageState[prevEndpoint];
|
|
542
|
-
removeRoute(RED.httpNode
|
|
543
|
+
removeRoute(getHttpRouter(RED.httpNode), prevEndpoint);
|
|
543
544
|
delete registeredRoutes[prevEndpoint];
|
|
544
545
|
if (endpointOwners[prevEndpoint] === nodeId) {
|
|
545
546
|
delete endpointOwners[prevEndpoint];
|
|
@@ -1596,7 +1597,7 @@ module.exports = function (RED) {
|
|
|
1596
1597
|
deleteCacheFiles(lastJsxHash);
|
|
1597
1598
|
}
|
|
1598
1599
|
delete pageState[endpoint];
|
|
1599
|
-
removeRoute(RED.httpNode
|
|
1600
|
+
removeRoute(getHttpRouter(RED.httpNode), endpoint);
|
|
1600
1601
|
delete registeredRoutes[endpoint];
|
|
1601
1602
|
}
|
|
1602
1603
|
|