geonix 1.22.5 → 1.23.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/package.json +1 -1
- package/src/Gateway.js +1 -1
- package/src/Service.js +6 -4
- package/src/WebServer.js +11 -5
- package/test/big_upload.js +0 -0
- package/test/gateway.js +12 -4
- package/test/pubsub.js +29 -0
package/package.json
CHANGED
package/src/Gateway.js
CHANGED
|
@@ -10,7 +10,7 @@ import semver from "semver";
|
|
|
10
10
|
import { WebSocket } from "ws";
|
|
11
11
|
import { logger } from "./Logger.js";
|
|
12
12
|
|
|
13
|
-
const raw = express.raw({ limit: "
|
|
13
|
+
const raw = express.raw({ limit: "1024mb" });
|
|
14
14
|
|
|
15
15
|
const DEBUG_ENDPOINT = "/lZ6jD2eC3iP0zB3jJ1yJ9pM8gG3yI3vS";
|
|
16
16
|
const endpointMatcher = /^((?<options>.+)\|)?(?<verb>WS|GET|POST|PATCH|PUT|DELETE|HEAD|OPTIONS|ALL)\s(?<url>.*)/;
|
package/src/Service.js
CHANGED
|
@@ -15,8 +15,8 @@ const isEndpointFilter = methodName => endpointMatcher.test(methodName);
|
|
|
15
15
|
const ERROR_BEGIN_DELIMITER = "-".repeat(10);
|
|
16
16
|
const ERROR_END_DELIMITER = "-".repeat(40);
|
|
17
17
|
|
|
18
|
-
const json = express.json({ limit: "
|
|
19
|
-
const raw = express.raw({ type: "*/*", limit: "
|
|
18
|
+
const json = express.json({ limit: "1024mb" });
|
|
19
|
+
const raw = express.raw({ type: "*/*", limit: "1024mb" });
|
|
20
20
|
const cookies = cookieParser();
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -226,8 +226,10 @@ export class Service {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
async #sub(
|
|
230
|
-
const
|
|
229
|
+
async #sub(_subject, handler) {
|
|
230
|
+
const [subject, queue] = _subject.split(",");
|
|
231
|
+
|
|
232
|
+
const subscription = await connection.subscribe(subject, { queue });
|
|
231
233
|
const processor = async () => {
|
|
232
234
|
for await (const event of subscription) {
|
|
233
235
|
handler(event.data);
|
package/src/WebServer.js
CHANGED
|
@@ -103,12 +103,18 @@ class WebServer {
|
|
|
103
103
|
|
|
104
104
|
let router = routers.shift();
|
|
105
105
|
while (router) {
|
|
106
|
-
router = await new Promise((resolve) => {
|
|
106
|
+
router = await new Promise((resolve, reject) => {
|
|
107
107
|
currentResolve = resolve;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
|
|
109
|
+
router(req, res,
|
|
110
|
+
(error, _req, _res, _next) => {
|
|
111
|
+
if (error) {
|
|
112
|
+
return reject(error);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// go to next router
|
|
116
|
+
resolve(routers.shift());
|
|
117
|
+
});
|
|
112
118
|
});
|
|
113
119
|
}
|
|
114
120
|
|
|
File without changes
|
package/test/gateway.js
CHANGED
|
@@ -8,13 +8,21 @@ class TestService extends Service {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async "POST /upload"(req, res) {
|
|
11
|
-
|
|
11
|
+
try {
|
|
12
|
+
const parts = await parseMultipart(req, { useMemory: false });
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
for (const part of parts) {
|
|
15
|
+
console.debug(part?.body);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
res.send("OK");
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(e);
|
|
15
21
|
}
|
|
22
|
+
}
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
"GET /test"(req, res) {
|
|
25
|
+
res.send("Hello World - /test");
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
}
|
package/test/pubsub.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Publish, Remote, Service } from "../exports.js";
|
|
2
|
+
import { sleep } from "../src/Util.js";
|
|
3
|
+
|
|
4
|
+
class TimeService extends Service {
|
|
5
|
+
|
|
6
|
+
counter = 0;
|
|
7
|
+
|
|
8
|
+
"SUB test,q1"(data) {
|
|
9
|
+
console.log(`SUB test (${this.counter++})`, data);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class ApplicationService extends Service {
|
|
15
|
+
|
|
16
|
+
async onStart() {
|
|
17
|
+
await sleep(1000);
|
|
18
|
+
|
|
19
|
+
while (true) {
|
|
20
|
+
await Publish("test", "Hello World");
|
|
21
|
+
await sleep(1000);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
TimeService.start();
|
|
28
|
+
TimeService.start();
|
|
29
|
+
ApplicationService.start();
|