geonix 1.23.6 → 1.30.2
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/LICENSE.md +1 -1
- package/README.md +348 -4
- package/exports.js +0 -2
- package/index.d.ts +292 -237
- package/package.json +11 -8
- package/src/Codec.js +20 -7
- package/src/Connection.js +94 -40
- package/src/Crypto.js +103 -0
- package/src/Gateway.js +155 -70
- package/src/Logger.js +90 -9
- package/src/Registry.js +133 -15
- package/src/Remote.js +15 -6
- package/src/Request.js +117 -80
- package/src/RequestOptions.js +11 -8
- package/src/Service.js +133 -91
- package/src/Stream.js +69 -15
- package/src/Util.js +196 -158
- package/src/WebServer.js +18 -10
- package/test/context.js +0 -35
- package/test/delayedStart.js +0 -24
- package/test/gateway.js +0 -34
- package/test/middleware.js +0 -24
- package/test/package.json +0 -16
- package/test/pubsub.js +0 -29
- package/test/simple.js +0 -29
- package/test/static/index.html +0 -1
- package/test/stream.js +0 -43
- package/test/upload.js +0 -34
- package/test/ws_auth.js +0 -21
package/test/package.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "test",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "stream.js",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [],
|
|
11
|
-
"author": "",
|
|
12
|
-
"license": "ISC",
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"geonix": "file:.."
|
|
15
|
-
}
|
|
16
|
-
}
|
package/test/pubsub.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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();
|
package/test/simple.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Remote, Service } from "../exports.js";
|
|
2
|
-
import { sleep } from "../src/Util.js";
|
|
3
|
-
|
|
4
|
-
class TimeService extends Service {
|
|
5
|
-
|
|
6
|
-
getCurrentTime() {
|
|
7
|
-
return new Date().toISOString();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
class ApplicationService extends Service {
|
|
13
|
-
|
|
14
|
-
#timeService = Remote("TimeService");
|
|
15
|
-
|
|
16
|
-
async onStart() {
|
|
17
|
-
while (true) {
|
|
18
|
-
const time = await this.#timeService.getCurrentTime();
|
|
19
|
-
|
|
20
|
-
console.log("TIME =", time);
|
|
21
|
-
|
|
22
|
-
await sleep(1000);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
TimeService.start();
|
|
29
|
-
ApplicationService.start();
|
package/test/static/index.html
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Works!
|
package/test/stream.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from "node:crypto";
|
|
2
|
-
import { Stream, getReadable, connection } from "geonix";
|
|
3
|
-
import { createWriteStream, readFileSync } from "node:fs";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
|
-
import { pipeline } from "node:stream/promises";
|
|
6
|
-
import { webserver } from "../src/WebServer.js";
|
|
7
|
-
|
|
8
|
-
await connection.waitUntilReady();
|
|
9
|
-
|
|
10
|
-
const hash = data => createHash("sha512").update(data).digest("base64");
|
|
11
|
-
|
|
12
|
-
const PAYLOAD_SIZE = 1024 * 1024 * 1024;
|
|
13
|
-
const TEMP_FILE = "/tmp/geonix.stream_test";
|
|
14
|
-
|
|
15
|
-
await webserver.start();
|
|
16
|
-
|
|
17
|
-
console.time("test");
|
|
18
|
-
try {
|
|
19
|
-
const payload = randomBytes(PAYLOAD_SIZE);
|
|
20
|
-
const sourceHash = hash(payload);
|
|
21
|
-
|
|
22
|
-
const stream = Stream(payload);
|
|
23
|
-
|
|
24
|
-
const source = await getReadable(stream);
|
|
25
|
-
const dest = createWriteStream(TEMP_FILE);
|
|
26
|
-
|
|
27
|
-
await pipeline(source, dest);
|
|
28
|
-
|
|
29
|
-
const check = readFileSync(TEMP_FILE);
|
|
30
|
-
const destHash = hash(check);
|
|
31
|
-
|
|
32
|
-
if (sourceHash == destHash) {
|
|
33
|
-
console.log("MATCH");
|
|
34
|
-
} else {
|
|
35
|
-
console.error("Destination does not match the source!");
|
|
36
|
-
console.log("P =", payload);
|
|
37
|
-
console.log("C =", check);
|
|
38
|
-
}
|
|
39
|
-
} catch (e) {
|
|
40
|
-
console.error(e);
|
|
41
|
-
} finally {
|
|
42
|
-
console.timeEnd("test");
|
|
43
|
-
}
|
package/test/upload.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { write } from "fs";
|
|
2
|
-
import { Service, streamToBuffer } from "../exports.js";
|
|
3
|
-
import { parseMultipart } from "../src/Util.js";
|
|
4
|
-
import { writeFile } from "fs/promises";
|
|
5
|
-
|
|
6
|
-
class UploadService extends Service {
|
|
7
|
-
|
|
8
|
-
async "POST /upload"(req, res) {
|
|
9
|
-
console.log(req.body);
|
|
10
|
-
let size = 0;
|
|
11
|
-
|
|
12
|
-
req.on("data", (chunk) => {
|
|
13
|
-
console.log(`size=${size}`);
|
|
14
|
-
size += chunk.length;
|
|
15
|
-
});
|
|
16
|
-
req.on("end", () => {
|
|
17
|
-
console.log(`size=${size}`);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// const files = await parseMultipart(req, { useMemory: false });
|
|
21
|
-
|
|
22
|
-
// for (const file of files) {
|
|
23
|
-
// file.body = await streamToBuffer(file.body);
|
|
24
|
-
// console.log(`${file.filename} ${file.headers["content-type"]} size=${file.body.length}`);
|
|
25
|
-
|
|
26
|
-
// await writeFile("/tmp/temp.pdf", file.body);
|
|
27
|
-
// }
|
|
28
|
-
|
|
29
|
-
res.send("ok");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
UploadService.start({ middleware: { raw: false } });
|
package/test/ws_auth.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Gateway, ServeStatic, Service } from "../exports.js";
|
|
2
|
-
|
|
3
|
-
class ServiceFirst extends Service {
|
|
4
|
-
"WS /ws/first" = (ws) => {
|
|
5
|
-
ws.on("message", (message) => {
|
|
6
|
-
ws.send("first:" + message);
|
|
7
|
-
});
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
class ServiceSecond extends Service {
|
|
12
|
-
"WS /ws/second" = (ws) => {
|
|
13
|
-
ws.on("message", (message) => {
|
|
14
|
-
ws.send("second:" + message);
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
Gateway.start();
|
|
20
|
-
ServiceFirst.start();
|
|
21
|
-
ServiceSecond.start();
|