systemlynx 1.9.3 → 1.9.4
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
package/systemlynx/App/App.js
CHANGED
|
@@ -11,11 +11,16 @@ module.exports = function createApp(server, WebSocket, customClient) {
|
|
|
11
11
|
const systemContext = SystemLynxContext(system);
|
|
12
12
|
const App = new createDispatcher(undefined, systemContext);
|
|
13
13
|
const plugins = [];
|
|
14
|
-
|
|
14
|
+
const init = () => {
|
|
15
15
|
plugins.forEach((plugin) => {
|
|
16
16
|
if (typeof plugin === "function") plugin.apply({}, [App, system]);
|
|
17
17
|
});
|
|
18
18
|
initializeApp(system, App, customClient, systemContext);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let timeoutId = setTimeout(() => {
|
|
22
|
+
timeoutId = null;
|
|
23
|
+
init();
|
|
19
24
|
}, 0);
|
|
20
25
|
|
|
21
26
|
if (isNode) {
|
|
@@ -23,6 +28,12 @@ module.exports = function createApp(server, WebSocket, customClient) {
|
|
|
23
28
|
|
|
24
29
|
App.startService = (options) => {
|
|
25
30
|
system.routing = options;
|
|
31
|
+
if (!timeoutId) {
|
|
32
|
+
timeoutId = setTimeout(() => {
|
|
33
|
+
timeoutId = null;
|
|
34
|
+
init();
|
|
35
|
+
}, 0);
|
|
36
|
+
}
|
|
26
37
|
return App;
|
|
27
38
|
};
|
|
28
39
|
|
|
@@ -6,11 +6,22 @@ module.exports = function createClient() {
|
|
|
6
6
|
const Client = this || {};
|
|
7
7
|
Client.request = ({ method, url, body }, cb) => {
|
|
8
8
|
const tryRequest = (callback) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const req = httpClient(
|
|
10
|
+
{
|
|
11
|
+
method,
|
|
12
|
+
url,
|
|
13
|
+
body,
|
|
14
|
+
json,
|
|
15
|
+
headers: {
|
|
16
|
+
Origin: "http://localhost:3000", // Replace with your desired origin
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
(err, res, body) => {
|
|
20
|
+
if (err) callback(err);
|
|
21
|
+
else if (res.statusCode >= 400) callback(body);
|
|
22
|
+
else callback(null, body, res);
|
|
23
|
+
}
|
|
24
|
+
);
|
|
14
25
|
};
|
|
15
26
|
if (typeof cb === "function") tryRequest(cb);
|
|
16
27
|
else
|