nyx-bot-client 0.0.3 → 0.0.4
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/biome.json +1 -1
- package/bun.lock +21 -36
- package/cron/actions-server.ts +4 -7
- package/nyx-client.ts +5 -8
- package/package.json +7 -8
- package/types.d.ts +2 -2
- package/utils/actions.ts +4 -4
- package/utils/table.ts +4 -5
package/biome.json
CHANGED
package/bun.lock
CHANGED
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
"": {
|
|
5
5
|
"name": "nyx-bot-client",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@biomejs/biome": "^2.2.
|
|
8
|
-
"@types/node": "^24.
|
|
9
|
-
"dotenv": "^17.2.
|
|
10
|
-
"kysely": "^0.28.
|
|
11
|
-
"mysql2": "^3.15.
|
|
12
|
-
"redis": "^5.8.2",
|
|
7
|
+
"@biomejs/biome": "^2.2.6",
|
|
8
|
+
"@types/node": "^24.7.2",
|
|
9
|
+
"dotenv": "^17.2.3",
|
|
10
|
+
"kysely": "^0.28.8",
|
|
11
|
+
"mysql2": "^3.15.2",
|
|
13
12
|
"ts-debounce": "^4.0.0",
|
|
14
|
-
"zod": "^4.1.
|
|
13
|
+
"zod": "^4.1.12",
|
|
15
14
|
},
|
|
16
15
|
"devDependencies": {
|
|
17
16
|
"@types/bun": "latest",
|
|
@@ -22,47 +21,35 @@
|
|
|
22
21
|
},
|
|
23
22
|
},
|
|
24
23
|
"packages": {
|
|
25
|
-
"@biomejs/biome": ["@biomejs/biome@2.2.
|
|
24
|
+
"@biomejs/biome": ["@biomejs/biome@2.2.6", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.2.6", "@biomejs/cli-darwin-x64": "2.2.6", "@biomejs/cli-linux-arm64": "2.2.6", "@biomejs/cli-linux-arm64-musl": "2.2.6", "@biomejs/cli-linux-x64": "2.2.6", "@biomejs/cli-linux-x64-musl": "2.2.6", "@biomejs/cli-win32-arm64": "2.2.6", "@biomejs/cli-win32-x64": "2.2.6" }, "bin": { "biome": "bin/biome" } }, "sha512-yKTCNGhek0rL5OEW1jbLeZX8LHaM8yk7+3JRGv08my+gkpmtb5dDE+54r2ZjZx0ediFEn1pYBOJSmOdDP9xtFw=="],
|
|
26
25
|
|
|
27
|
-
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.2.
|
|
26
|
+
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.2.6", "", { "os": "darwin", "cpu": "arm64" }, "sha512-UZPmn3M45CjTYulgcrFJFZv7YmK3pTxTJDrFYlNElT2FNnkkX4fsxjExTSMeWKQYoZjvekpH5cvrYZZlWu3yfA=="],
|
|
28
27
|
|
|
29
|
-
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.2.
|
|
28
|
+
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.2.6", "", { "os": "darwin", "cpu": "x64" }, "sha512-HOUIquhHVgh/jvxyClpwlpl/oeMqntlteL89YqjuFDiZ091P0vhHccwz+8muu3nTyHWM5FQslt+4Jdcd67+xWQ=="],
|
|
30
29
|
|
|
31
|
-
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.2.
|
|
30
|
+
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.2.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-BpGtuMJGN+o8pQjvYsUKZ+4JEErxdSmcRD/JG3mXoWc6zrcA7OkuyGFN1mDggO0Q1n7qXxo/PcupHk8gzijt5g=="],
|
|
32
31
|
|
|
33
|
-
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.2.
|
|
32
|
+
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.2.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-TjCenQq3N6g1C+5UT3jE1bIiJb5MWQvulpUngTIpFsL4StVAUXucWD0SL9MCW89Tm6awWfeXBbZBAhJwjyFbRQ=="],
|
|
34
33
|
|
|
35
|
-
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.2.
|
|
34
|
+
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.2.6", "", { "os": "linux", "cpu": "x64" }, "sha512-1HaM/dpI/1Z68zp8ZdT6EiBq+/O/z97a2AiHMl+VAdv5/ELckFt9EvRb8hDHpk8hUMoz03gXkC7VPXOVtU7faA=="],
|
|
36
35
|
|
|
37
|
-
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.2.
|
|
36
|
+
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.2.6", "", { "os": "linux", "cpu": "x64" }, "sha512-1ZcBux8zVM3JhWN2ZCPaYf0+ogxXG316uaoXJdgoPZcdK/rmRcRY7PqHdAos2ExzvjIdvhQp72UcveI98hgOog=="],
|
|
38
37
|
|
|
39
|
-
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.2.
|
|
38
|
+
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.2.6", "", { "os": "win32", "cpu": "arm64" }, "sha512-h3A88G8PGM1ryTeZyLlSdfC/gz3e95EJw9BZmA6Po412DRqwqPBa2Y9U+4ZSGUAXCsnSQE00jLV8Pyrh0d+jQw=="],
|
|
40
39
|
|
|
41
|
-
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.2.
|
|
42
|
-
|
|
43
|
-
"@redis/bloom": ["@redis/bloom@5.8.2", "", { "peerDependencies": { "@redis/client": "^5.8.2" } }, "sha512-855DR0ChetZLarblio5eM0yLwxA9Dqq50t8StXKp5bAtLT0G+rZ+eRzzqxl37sPqQKjUudSYypz55o6nNhbz0A=="],
|
|
44
|
-
|
|
45
|
-
"@redis/client": ["@redis/client@5.8.2", "", { "dependencies": { "cluster-key-slot": "1.1.2" } }, "sha512-WtMScno3+eBpTac1Uav2zugXEoXqaU23YznwvFgkPwBQVwEHTDgOG7uEAObtZ/Nyn8SmAMbqkEubJaMOvnqdsQ=="],
|
|
46
|
-
|
|
47
|
-
"@redis/json": ["@redis/json@5.8.2", "", { "peerDependencies": { "@redis/client": "^5.8.2" } }, "sha512-uxpVfas3I0LccBX9rIfDgJ0dBrUa3+0Gc8sEwmQQH0vHi7C1Rx1Qn8Nv1QWz5bohoeIXMICFZRcyDONvum2l/w=="],
|
|
48
|
-
|
|
49
|
-
"@redis/search": ["@redis/search@5.8.2", "", { "peerDependencies": { "@redis/client": "^5.8.2" } }, "sha512-cNv7HlgayavCBXqPXgaS97DRPVWFznuzsAmmuemi2TMCx5scwLiP50TeZvUS06h/MG96YNPe6A0Zt57yayfxwA=="],
|
|
50
|
-
|
|
51
|
-
"@redis/time-series": ["@redis/time-series@5.8.2", "", { "peerDependencies": { "@redis/client": "^5.8.2" } }, "sha512-g2NlHM07fK8H4k+613NBsk3y70R2JIM2dPMSkhIjl2Z17SYvaYKdusz85d7VYOrZBWtDrHV/WD2E3vGu+zni8A=="],
|
|
40
|
+
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.2.6", "", { "os": "win32", "cpu": "x64" }, "sha512-yx0CqeOhPjYQ5ZXgPfu8QYkgBhVJyvWe36as7jRuPrKPO5ylVDfwVtPQ+K/mooNTADW0IhxOZm3aPu16dP8yNQ=="],
|
|
52
41
|
|
|
53
42
|
"@types/bun": ["@types/bun@1.2.17", "", { "dependencies": { "bun-types": "1.2.17" } }, "sha512-l/BYs/JYt+cXA/0+wUhulYJB6a6p//GTPiJ7nV+QHa8iiId4HZmnu/3J/SowP5g0rTiERY2kfGKXEK5Ehltx4Q=="],
|
|
54
43
|
|
|
55
|
-
"@types/node": ["@types/node@24.
|
|
44
|
+
"@types/node": ["@types/node@24.7.2", "", { "dependencies": { "undici-types": "~7.14.0" } }, "sha512-/NbVmcGTP+lj5oa4yiYxxeBjRivKQ5Ns1eSZeB99ExsEQ6rX5XYU1Zy/gGxY/ilqtD4Etx9mKyrPxZRetiahhA=="],
|
|
56
45
|
|
|
57
46
|
"aws-ssl-profiles": ["aws-ssl-profiles@1.1.2", "", {}, "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g=="],
|
|
58
47
|
|
|
59
48
|
"bun-types": ["bun-types@1.2.17", "", { "dependencies": { "@types/node": "*" } }, "sha512-ElC7ItwT3SCQwYZDYoAH+q6KT4Fxjl8DtZ6qDulUFBmXA8YB4xo+l54J9ZJN+k2pphfn9vk7kfubeSd5QfTVJQ=="],
|
|
60
49
|
|
|
61
|
-
"cluster-key-slot": ["cluster-key-slot@1.1.2", "", {}, "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA=="],
|
|
62
|
-
|
|
63
50
|
"denque": ["denque@2.1.0", "", {}, "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw=="],
|
|
64
51
|
|
|
65
|
-
"dotenv": ["dotenv@17.2.
|
|
52
|
+
"dotenv": ["dotenv@17.2.3", "", {}, "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w=="],
|
|
66
53
|
|
|
67
54
|
"generate-function": ["generate-function@2.3.1", "", { "dependencies": { "is-property": "^1.0.2" } }, "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ=="],
|
|
68
55
|
|
|
@@ -70,7 +57,7 @@
|
|
|
70
57
|
|
|
71
58
|
"is-property": ["is-property@1.0.2", "", {}, "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g=="],
|
|
72
59
|
|
|
73
|
-
"kysely": ["kysely@0.28.
|
|
60
|
+
"kysely": ["kysely@0.28.8", "", {}, "sha512-QUOgl5ZrS9IRuhq5FvOKFSsD/3+IA6MLE81/bOOTRA/YQpKDza2sFdN5g6JCB9BOpqMJDGefLCQ9F12hRS13TA=="],
|
|
74
61
|
|
|
75
62
|
"long": ["long@5.3.2", "", {}, "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA=="],
|
|
76
63
|
|
|
@@ -78,12 +65,10 @@
|
|
|
78
65
|
|
|
79
66
|
"lru.min": ["lru.min@1.1.2", "", {}, "sha512-Nv9KddBcQSlQopmBHXSsZVY5xsdlZkdH/Iey0BlcBYggMd4two7cZnKOK9vmy3nY0O5RGH99z1PCeTpPqszUYg=="],
|
|
80
67
|
|
|
81
|
-
"mysql2": ["mysql2@3.15.
|
|
68
|
+
"mysql2": ["mysql2@3.15.2", "", { "dependencies": { "aws-ssl-profiles": "^1.1.1", "denque": "^2.1.0", "generate-function": "^2.3.1", "iconv-lite": "^0.7.0", "long": "^5.2.1", "lru.min": "^1.0.0", "named-placeholders": "^1.1.3", "seq-queue": "^0.0.5", "sqlstring": "^2.3.2" } }, "sha512-kFm5+jbwR5mC+lo+3Cy46eHiykWSpUtTLOH3GE+AR7GeLq8PgfJcvpMiyVWk9/O53DjQsqm6a3VOOfq7gYWFRg=="],
|
|
82
69
|
|
|
83
70
|
"named-placeholders": ["named-placeholders@1.1.3", "", { "dependencies": { "lru-cache": "^7.14.1" } }, "sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w=="],
|
|
84
71
|
|
|
85
|
-
"redis": ["redis@5.8.2", "", { "dependencies": { "@redis/bloom": "5.8.2", "@redis/client": "5.8.2", "@redis/json": "5.8.2", "@redis/search": "5.8.2", "@redis/time-series": "5.8.2" } }, "sha512-31vunZj07++Y1vcFGcnNWEf5jPoTkGARgfWI4+Tk55vdwHxhAvug8VEtW7Cx+/h47NuJTEg/JL77zAwC6E0OeA=="],
|
|
86
|
-
|
|
87
72
|
"safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
|
|
88
73
|
|
|
89
74
|
"seq-queue": ["seq-queue@0.0.5", "", {}, "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q=="],
|
|
@@ -94,9 +79,9 @@
|
|
|
94
79
|
|
|
95
80
|
"typescript": ["typescript@5.8.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="],
|
|
96
81
|
|
|
97
|
-
"undici-types": ["undici-types@7.
|
|
82
|
+
"undici-types": ["undici-types@7.14.0", "", {}, "sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA=="],
|
|
98
83
|
|
|
99
|
-
"zod": ["zod@4.1.
|
|
84
|
+
"zod": ["zod@4.1.12", "", {}, "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ=="],
|
|
100
85
|
|
|
101
86
|
"bun-types/@types/node": ["@types/node@24.0.4", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-ulyqAkrhnuNq9pB76DRBTkcS6YsmDALy6Ua63V8OhrOBgbcYt6IOdzpw5P1+dyRIyMerzLkeYWBeOXPpA9GMAA=="],
|
|
102
87
|
|
package/cron/actions-server.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Cron: @reboot
|
|
2
2
|
|
|
3
|
+
import { RedisClient } from "bun";
|
|
3
4
|
import dotenv from "dotenv";
|
|
4
5
|
import { Kysely, MysqlDialect } from "kysely";
|
|
5
6
|
import { createPool } from "mysql2";
|
|
6
|
-
import { createClient } from "redis";
|
|
7
7
|
import z from "zod";
|
|
8
8
|
import type { NyxAction } from "../utils/actions";
|
|
9
9
|
import * as methods from "../utils/methods";
|
|
@@ -47,12 +47,9 @@ const db = new Kysely<{
|
|
|
47
47
|
}),
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
const redis =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
port: env.BROKER_REDIS_PORT,
|
|
54
|
-
}
|
|
55
|
-
});
|
|
50
|
+
const redis = new RedisClient(
|
|
51
|
+
`redis://${env.BROKER_REDIS_HOST}:${env.BROKER_REDIS_PORT}`,
|
|
52
|
+
);
|
|
56
53
|
await redis.connect();
|
|
57
54
|
|
|
58
55
|
redis.subscribe("nyx-action", async (input) => {
|
package/nyx-client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RedisClient } from "bun";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { EventTypes } from "./@types";
|
|
4
4
|
import type {
|
|
@@ -31,15 +31,12 @@ class NyxClient {
|
|
|
31
31
|
public injections: BotInjections | undefined;
|
|
32
32
|
public benchmark: boolean | undefined;
|
|
33
33
|
|
|
34
|
-
private redis:
|
|
34
|
+
private redis: RedisClient | undefined;
|
|
35
35
|
|
|
36
36
|
public async initialize(config: NyxConfig) {
|
|
37
|
-
this.redis =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
port: config.redis?.port ?? 6379,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
37
|
+
this.redis = new RedisClient(
|
|
38
|
+
`redis://${config.redis?.host ?? "127.0.0.1"}:${config.redis?.port ?? 6379}`,
|
|
39
|
+
);
|
|
43
40
|
|
|
44
41
|
this.botConfig = z
|
|
45
42
|
.object({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nyx-bot-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
"typescript": "^5"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@biomejs/biome": "^2.2.
|
|
14
|
-
"@types/node": "^24.
|
|
15
|
-
"dotenv": "^17.2.
|
|
16
|
-
"kysely": "^0.28.
|
|
17
|
-
"mysql2": "^3.15.
|
|
18
|
-
"redis": "^5.8.2",
|
|
13
|
+
"@biomejs/biome": "^2.2.6",
|
|
14
|
+
"@types/node": "^24.7.2",
|
|
15
|
+
"dotenv": "^17.2.3",
|
|
16
|
+
"kysely": "^0.28.8",
|
|
17
|
+
"mysql2": "^3.15.2",
|
|
19
18
|
"ts-debounce": "^4.0.0",
|
|
20
|
-
"zod": "^4.1.
|
|
19
|
+
"zod": "^4.1.12"
|
|
21
20
|
}
|
|
22
21
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { RedisClient } from "bun";
|
|
1
2
|
import type { Kysely } from "kysely";
|
|
2
3
|
import type { Connection, Pool } from "mysql2";
|
|
3
|
-
import type { RedisClientType } from "redis";
|
|
4
4
|
import type { EventTypes } from "./@types";
|
|
5
5
|
import type { NyxResponse } from "./utils/enum";
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ export type BotInjections = () => Promise<{
|
|
|
29
29
|
|
|
30
30
|
export type Injections<T> = {
|
|
31
31
|
mysql?: Connection | Pool;
|
|
32
|
-
redis?:
|
|
32
|
+
redis?: RedisClient;
|
|
33
33
|
db?: Kysely<T>;
|
|
34
34
|
[key: string]: any;
|
|
35
35
|
};
|
package/utils/actions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RedisClient } from "bun";
|
|
2
2
|
import type * as methods from "./methods.ts";
|
|
3
3
|
|
|
4
4
|
type MethodName = keyof typeof methods;
|
|
@@ -13,7 +13,7 @@ export type NyxAction<T extends MethodName = MethodName> = {
|
|
|
13
13
|
date: number;
|
|
14
14
|
bot_token: string;
|
|
15
15
|
bot_api_server?: string;
|
|
16
|
-
redis?:
|
|
16
|
+
redis?: RedisClient;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const actionBroker = async <T extends MethodName>(
|
|
@@ -22,9 +22,9 @@ export const actionBroker = async <T extends MethodName>(
|
|
|
22
22
|
if (action.redis) {
|
|
23
23
|
await action.redis.publish("nyx-action", JSON.stringify(action));
|
|
24
24
|
} else {
|
|
25
|
-
const redis =
|
|
25
|
+
const redis = new RedisClient();
|
|
26
26
|
await redis.connect();
|
|
27
27
|
await redis.publish("nyx-action", JSON.stringify(action));
|
|
28
|
-
|
|
28
|
+
redis.close();
|
|
29
29
|
}
|
|
30
30
|
};
|
package/utils/table.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RedisClient } from "bun";
|
|
2
2
|
import { debounce } from "ts-debounce";
|
|
3
3
|
import { createReactiveObject } from "./objects";
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ class NyxTable<T> {
|
|
|
13
13
|
private pid: string;
|
|
14
14
|
private options: NyxTableOptions<T> | undefined;
|
|
15
15
|
private schema: T;
|
|
16
|
-
private redis:
|
|
16
|
+
private redis: RedisClient;
|
|
17
17
|
private key: string;
|
|
18
18
|
private channel: string;
|
|
19
19
|
private handleUpdate: (() => void) | undefined;
|
|
@@ -23,7 +23,7 @@ class NyxTable<T> {
|
|
|
23
23
|
constructor(
|
|
24
24
|
uid: string,
|
|
25
25
|
schema: T,
|
|
26
|
-
redis:
|
|
26
|
+
redis: RedisClient,
|
|
27
27
|
options?: NyxTableOptions<T>,
|
|
28
28
|
) {
|
|
29
29
|
this.uid = uid;
|
|
@@ -58,8 +58,7 @@ class NyxTable<T> {
|
|
|
58
58
|
await this.options?.onInternalUpdate?.(this.table);
|
|
59
59
|
}, this.options?.persistenceDebounceMillis ?? 1_000);
|
|
60
60
|
|
|
61
|
-
const redisSub = this.redis.duplicate();
|
|
62
|
-
await redisSub.connect();
|
|
61
|
+
const redisSub = await this.redis.duplicate();
|
|
63
62
|
redisSub.subscribe(this.channel, async (pid) => {
|
|
64
63
|
if (pid !== this.pid) {
|
|
65
64
|
this.assignTable(JSON.parse((await this.redis.get(this.key))!));
|