systemlynx 1.8.3 → 1.9.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/package.json
CHANGED
|
@@ -5,17 +5,19 @@ module.exports = function loadConnectionData(
|
|
|
5
5
|
) {
|
|
6
6
|
const errors = [];
|
|
7
7
|
|
|
8
|
-
return new Promise(function getData(resolve) {
|
|
8
|
+
return new Promise(function getData(resolve, reject) {
|
|
9
9
|
httpClient.request({ method: "GET", url }, (err, results) => {
|
|
10
10
|
if (err) {
|
|
11
11
|
errors.push(err);
|
|
12
12
|
|
|
13
13
|
if (errors.length < limit)
|
|
14
|
-
setTimeout(() => getData(resolve), errors.length * wait);
|
|
15
|
-
else
|
|
14
|
+
setTimeout(() => getData(resolve, reject), errors.length * wait);
|
|
15
|
+
else {
|
|
16
16
|
console.error(
|
|
17
17
|
`[SystemLynx][Client][Error]: Failed to load Service @${url} after ${errors.length} attempts.`
|
|
18
18
|
);
|
|
19
|
+
reject(err);
|
|
20
|
+
}
|
|
19
21
|
} else resolve(results);
|
|
20
22
|
});
|
|
21
23
|
});
|
|
@@ -138,6 +138,14 @@ module.exports = function createServerManager(customServer, customWebSocketServe
|
|
|
138
138
|
ServerManager.addRouteHandler = (...args) => {
|
|
139
139
|
const name = typeof args[0] === "string" ? args.shift() : "$all";
|
|
140
140
|
args.forEach(async (middleware) => {
|
|
141
|
+
if (Array.isArray(middleware)) {
|
|
142
|
+
middleware.map(addMiddleware);
|
|
143
|
+
} else {
|
|
144
|
+
addMiddleware(middleware);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
function addMiddleware(middleware) {
|
|
141
149
|
if (!serverConfigurations.validators[name])
|
|
142
150
|
serverConfigurations.validators[name] = [];
|
|
143
151
|
serverConfigurations.validators[name].push(async function (req, res, next) {
|
|
@@ -147,7 +155,7 @@ module.exports = function createServerManager(customServer, customWebSocketServe
|
|
|
147
155
|
res.sendError(error);
|
|
148
156
|
}
|
|
149
157
|
});
|
|
150
|
-
}
|
|
158
|
+
}
|
|
151
159
|
};
|
|
152
160
|
return ServerManager;
|
|
153
161
|
};
|