systemlynx 1.16.11 → 1.17.11
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
|
@@ -23,6 +23,7 @@ module.exports = function createServerManager(customServer) {
|
|
|
23
23
|
ssl: { key: "", cert: "" },
|
|
24
24
|
beforeware: { $all: [] },
|
|
25
25
|
afterware: { $all: [] },
|
|
26
|
+
protocol: "http",
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
const server = createServer(customServer);
|
|
@@ -33,14 +34,13 @@ module.exports = function createServerManager(customServer) {
|
|
|
33
34
|
const ServerManager = { server };
|
|
34
35
|
|
|
35
36
|
ServerManager.startService = (options) => {
|
|
36
|
-
let { route, host = "localhost", port, staticRouting, ssl } = options;
|
|
37
|
+
let { route, host = "localhost", port, staticRouting, ssl, protocol } = options;
|
|
37
38
|
|
|
38
39
|
route = route.charAt(0) === "/" ? route.substr(1) : route;
|
|
39
40
|
route = route.charAt(route.length - 1) === "/" ? route.slice(0, -1) : route;
|
|
40
41
|
|
|
41
42
|
const namespace = staticRouting ? route : shortId();
|
|
42
|
-
|
|
43
|
-
const protocol = ssl ? "https" : "http";
|
|
43
|
+
if (!["http", "https"].includes(protocol)) protocol = ssl ? "https" : "http";
|
|
44
44
|
const serviceUrl = `${protocol}://${host}:${port}/${route}`;
|
|
45
45
|
|
|
46
46
|
const httpServer = ssl ? https.createServer(ssl, server) : http.createServer(server);
|
|
@@ -49,16 +49,7 @@ module.exports = function createServerManager(customServer) {
|
|
|
49
49
|
|
|
50
50
|
SocketEmitter.apply(ServerManager, [namespace, WebSocket]);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
...options,
|
|
54
|
-
server: httpServer,
|
|
55
|
-
WebSocket,
|
|
56
|
-
serviceUrl,
|
|
57
|
-
route,
|
|
58
|
-
port,
|
|
59
|
-
ssl,
|
|
60
|
-
});
|
|
61
|
-
const wsProtocol = ssl ? "wss" : "ws";
|
|
52
|
+
const wsProtocol = protocol === "https" ? "wss" : "ws";
|
|
62
53
|
|
|
63
54
|
const connectionData = {
|
|
64
55
|
modules,
|
|
@@ -70,6 +61,16 @@ module.exports = function createServerManager(customServer) {
|
|
|
70
61
|
SystemLynxService: true,
|
|
71
62
|
};
|
|
72
63
|
|
|
64
|
+
Object.assign(serverConfigurations, {
|
|
65
|
+
...options,
|
|
66
|
+
server: httpServer,
|
|
67
|
+
WebSocket,
|
|
68
|
+
serviceUrl,
|
|
69
|
+
route,
|
|
70
|
+
port,
|
|
71
|
+
protocol,
|
|
72
|
+
});
|
|
73
|
+
|
|
73
74
|
server.get(`/${route}`, (req, res) => {
|
|
74
75
|
res.json({ ...connectionData, modules });
|
|
75
76
|
});
|
|
@@ -98,7 +99,7 @@ module.exports = function createServerManager(customServer) {
|
|
|
98
99
|
beforeware,
|
|
99
100
|
afterware,
|
|
100
101
|
WebSocket,
|
|
101
|
-
|
|
102
|
+
protocol,
|
|
102
103
|
} = serverConfigurations;
|
|
103
104
|
|
|
104
105
|
if (!serviceUrl) return moduleQueue.push({ name, Module, reserved_methods });
|
|
@@ -121,7 +122,7 @@ module.exports = function createServerManager(customServer) {
|
|
|
121
122
|
|
|
122
123
|
if (useService) {
|
|
123
124
|
const path = staticRouting ? `${route}/${name}` : `${shortId()}/${shortId()}`;
|
|
124
|
-
const wsProtocol =
|
|
125
|
+
const wsProtocol = protocol === "https" ? "wss" : "ws";
|
|
125
126
|
|
|
126
127
|
modules.push({
|
|
127
128
|
namespace: `${wsProtocol}://${host}:${port}/${namespace}`,
|