badmfck-api-server 2.4.3 → 2.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -83,7 +83,7 @@ async function Initializer(services) {
83
83
  exports.Initializer = Initializer;
84
84
  class APIService extends BaseService_1.BaseService {
85
85
  static nextLogID = 0;
86
- version = "2.4.2";
86
+ version = "2.4.4";
87
87
  options;
88
88
  monitor;
89
89
  monitorIndexFile;
@@ -1,11 +1,12 @@
1
1
  import { BaseService } from "./BaseService";
2
2
  import { HUBConnection } from "./cluster/HUBConnection";
3
+ import Signal, { Req } from "badmfck-signal";
3
4
  export interface ClusterServiceOptions {
4
5
  id: string;
5
6
  privateKey: string;
6
7
  hubURL: string;
7
8
  hubPublicKey: string;
8
- nodes: string[];
9
+ nodes: (Signal<any> | Req<any, any>)[];
9
10
  }
10
11
  export declare class ClusterService extends BaseService {
11
12
  options: ClusterServiceOptions;
@@ -29,6 +29,7 @@ class ClusterService extends BaseService_1.BaseService {
29
29
  ws: new ws_1.default(this.options.hubURL),
30
30
  privateKey: this.options.privateKey,
31
31
  hubID: this.options.id,
32
+ handlers: this.options.nodes,
32
33
  onAuthorized: () => {
33
34
  this.ws?.send({
34
35
  method: "auth",
@@ -43,7 +44,6 @@ class ClusterService extends BaseService_1.BaseService {
43
44
  console.log("ClusterService: connection to HUB closed");
44
45
  this.connectToHUB();
45
46
  },
46
- handlers: []
47
47
  });
48
48
  }
49
49
  }
@@ -4,13 +4,14 @@ import Signal, { Req } from "badmfck-signal";
4
4
  import { IError } from "./structures/Interfaces";
5
5
  export interface HUBServiceOptions {
6
6
  url: string;
7
- privateKey: string;
7
+ hubPrivateKey: string;
8
8
  hubID: string;
9
9
  }
10
10
  export interface IClusterNode {
11
11
  clusterID: string;
12
12
  url: string;
13
13
  publicKey: string;
14
+ privateKey: string;
14
15
  ws: HUBConnection[];
15
16
  }
16
17
  export declare const REQ_CLUSTER_NODE: Req<string, IError | {
@@ -28,7 +28,7 @@ class HUBService extends BaseService_1.BaseService {
28
28
  wss.on("connection", (ws) => {
29
29
  const conn = new HUBConnection_1.HUBConnection({
30
30
  ws: ws,
31
- privateKey: this.options.privateKey,
31
+ privateKey: this.options.hubPrivateKey,
32
32
  hubID: this.options.hubID,
33
33
  onAuthorized: () => this.onConnectionAuthorized(conn),
34
34
  onClose: () => this.onConnectionClosed(conn),
@@ -48,6 +48,7 @@ class HUBService extends BaseService_1.BaseService {
48
48
  clusterID: conn.clientID,
49
49
  url: conn.url,
50
50
  publicKey: conn.publicKey,
51
+ privateKey: "123",
51
52
  ws: []
52
53
  };
53
54
  this.nodes.set(conn.clientID, clusterNode);
@@ -41,7 +41,7 @@ class HUBConnection {
41
41
  onAuthorized;
42
42
  intervalID = 0;
43
43
  constructor(options) {
44
- (0, LogService_1.logInfo)("HUBConnection: new connection");
44
+ (0, LogService_1.logInfo)("HUBConnection: new connection", options.ws.url);
45
45
  this.privateKey = options.privateKey;
46
46
  this.publicKey = null;
47
47
  this.hubID = options.hubID;
package/dist/index.d.ts CHANGED
@@ -7,4 +7,7 @@ import { ErrorUtils } from "./apiServer/structures/DefaultErrors";
7
7
  import { S_MONITOR_REGISTRATE_ACTION } from "./apiServer/monitor/Monitor";
8
8
  import { DataProvider } from "./apiServer/helper/DataProvider";
9
9
  import { UID } from "./apiServer/helper/UID";
10
- export { UID, APIService, Initializer, LocalRequest, MysqlService, Validator, LogService, DataProvider, ErrorUtils, S_MONITOR_REGISTRATE_ACTION };
10
+ import { HUBService } from "./apiServer/HUBService";
11
+ import { HUBConnection } from "./apiServer/cluster/HUBConnection";
12
+ import { ClusterService } from "./apiServer/ClusterService";
13
+ export { UID, APIService, Initializer, LocalRequest, MysqlService, Validator, LogService, DataProvider, ErrorUtils, HUBService, ClusterService, HUBConnection, S_MONITOR_REGISTRATE_ACTION };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.S_MONITOR_REGISTRATE_ACTION = exports.ErrorUtils = exports.DataProvider = exports.LogService = exports.Validator = exports.MysqlService = exports.LocalRequest = exports.Initializer = exports.APIService = exports.UID = void 0;
3
+ exports.S_MONITOR_REGISTRATE_ACTION = exports.HUBConnection = exports.ClusterService = exports.HUBService = exports.ErrorUtils = exports.DataProvider = exports.LogService = exports.Validator = exports.MysqlService = exports.LocalRequest = exports.Initializer = exports.APIService = exports.UID = void 0;
4
4
  const APIService_1 = require("./apiServer/APIService");
5
5
  Object.defineProperty(exports, "APIService", { enumerable: true, get: function () { return APIService_1.APIService; } });
6
6
  Object.defineProperty(exports, "Initializer", { enumerable: true, get: function () { return APIService_1.Initializer; } });
@@ -20,3 +20,9 @@ const DataProvider_1 = require("./apiServer/helper/DataProvider");
20
20
  Object.defineProperty(exports, "DataProvider", { enumerable: true, get: function () { return DataProvider_1.DataProvider; } });
21
21
  const UID_1 = require("./apiServer/helper/UID");
22
22
  Object.defineProperty(exports, "UID", { enumerable: true, get: function () { return UID_1.UID; } });
23
+ const HUBService_1 = require("./apiServer/HUBService");
24
+ Object.defineProperty(exports, "HUBService", { enumerable: true, get: function () { return HUBService_1.HUBService; } });
25
+ const HUBConnection_1 = require("./apiServer/cluster/HUBConnection");
26
+ Object.defineProperty(exports, "HUBConnection", { enumerable: true, get: function () { return HUBConnection_1.HUBConnection; } });
27
+ const ClusterService_1 = require("./apiServer/ClusterService");
28
+ Object.defineProperty(exports, "ClusterService", { enumerable: true, get: function () { return ClusterService_1.ClusterService; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "2.4.3",
3
+ "version": "2.4.5",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",