geonix 1.20.6 → 1.20.8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonix",
3
- "version": "1.20.6",
3
+ "version": "1.20.8",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "bin": {
@@ -17,11 +17,11 @@
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
19
  "cookie-parser": "1.4.6",
20
- "express": "4.20.0",
20
+ "express": "4.21.0",
21
21
  "express-async-errors": "3.1.1",
22
22
  "express-ws": "5.0.2",
23
23
  "nats": "2.28.2",
24
- "semver": "^7.6.3",
24
+ "semver": "7.6.3",
25
25
  "ws": "8.18.0"
26
26
  },
27
27
  "publishConfig": {
package/src/Gateway.js CHANGED
@@ -279,7 +279,7 @@ export class Gateway {
279
279
  }
280
280
 
281
281
  async #proxyHttpOverNats(streamId, entry, client) {
282
- if (await Request(entry.n, "SYS_createConnection", [streamId])) {
282
+ if (await Request(entry.n, "$createConnection", [streamId])) {
283
283
  const ingress = await connection.subscribe(`gx2.stream.${streamId}.a`);
284
284
 
285
285
  client.on("data", (chunk) => connection.publishRaw(`gx2.stream.${streamId}.b`, chunk));
package/src/Service.js CHANGED
@@ -205,8 +205,10 @@ export class Service {
205
205
 
206
206
  handlers = [...handlersBefore, ...handlers, ...handlersAfter];
207
207
 
208
+ // wrap handlers to ensure they are called with the correct context
208
209
  for (let n = 0; n < handlers.length; n++) {
209
- handlers[n] = handlers[n].bind(this);
210
+ const handler = handlers[n];
211
+ handlers[n] = (...args) => handler.apply(this, args);
210
212
  }
211
213
 
212
214
  switch (verb) {
@@ -215,7 +217,7 @@ export class Service {
215
217
  break;
216
218
 
217
219
  case "sub":
218
- this.#sub(uri, this[endpoint]);
220
+ this.#sub(uri, this[endpoint].bind(this));
219
221
  break;
220
222
 
221
223
  default:
@@ -0,0 +1,24 @@
1
+ import { Router } from "express";
2
+ import { ServeStatic, Service } from "../exports.js";
3
+
4
+ function special(req, res) {
5
+ console.log("THIS:", this);
6
+
7
+ res.send(`Hello ${this.value}`);
8
+ };
9
+
10
+ class ApplicationService extends Service {
11
+
12
+ value = "World!";
13
+
14
+ async onStart() {
15
+ }
16
+
17
+ "GET *" = [special, ServeStatic("test/static", { indexOn404: true })];
18
+ // "GET *" = [(req, res) => {
19
+ // res.send(`Hello ${this.value}`);
20
+ // }];
21
+
22
+ }
23
+
24
+ ApplicationService.start();
@@ -0,0 +1 @@
1
+ Works!
@@ -1,39 +0,0 @@
1
- import { randomBytes } from "node:crypto";
2
- import { createHash } from "node:crypto";
3
- import { Remote, Service } from "geonix";
4
-
5
- const hash = data => createHash("sha512").update(data).digest("base64");
6
-
7
- const payload = randomBytes(1024 * 1024 * 100);
8
-
9
- class Sender extends Service {
10
-
11
- async onStart() {
12
-
13
- const payloadHash = hash(payload);
14
-
15
- const recipient = Remote("Recipient");
16
-
17
- const result = await recipient.validate(payloadHash, payload.toString("base64"));
18
-
19
- if (result) {
20
- console.log("MATCH");
21
- } else {
22
- console.error("Destination does not match the source!");
23
- }
24
- }
25
-
26
- }
27
-
28
- class Recipient extends Service {
29
-
30
- async validate(originalHash, data) {
31
- const validationHash = hash(Buffer.from(data, "base64"));
32
-
33
- return validationHash === originalHash;
34
- }
35
-
36
- }
37
-
38
- Sender.start();
39
- Recipient.start();