@bejibun/redis 0.1.17 → 0.1.21
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/CHANGELOG.md +32 -0
- package/{dist/builders → builders}/RedisBuilder.js +32 -35
- package/bun.lock +218 -0
- package/{dist/exceptions → exceptions}/RedisException.js +1 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +25 -47
- package/src/builders/RedisBuilder.ts +240 -0
- package/src/config/redis.ts +15 -0
- package/src/exceptions/RedisException.ts +15 -0
- package/src/facades/Redis.ts +49 -0
- package/src/index.ts +3 -0
- package/tsconfig.json +17 -0
- package/types/index.d.ts +3 -0
- package/types/redis.d.ts +16 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- /package/{dist/builders → builders}/RedisBuilder.d.ts +0 -0
- /package/{dist/config → config}/redis.d.ts +0 -0
- /package/{dist/config → config}/redis.js +0 -0
- /package/{dist/exceptions → exceptions}/RedisException.d.ts +0 -0
- /package/{dist/facades → facades}/Redis.d.ts +0 -0
- /package/{dist/facades → facades}/Redis.js +0 -0
- /package/{dist → src}/types/index.d.ts +0 -0
- /package/{dist → src}/types/redis.d.ts +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## [v0.1.0](https://github.com/crenata/bejibun-redis/compare/v0.1.0...v0.1.0) - 2025-10-12
|
|
7
|
+
|
|
8
|
+
### 🩹 Fixes
|
|
9
|
+
|
|
10
|
+
### 📖 Changes
|
|
11
|
+
New Features :
|
|
12
|
+
- Redis
|
|
13
|
+
|
|
14
|
+
Available Redis :
|
|
15
|
+
- `.connection()` Multiple redis services
|
|
16
|
+
- `.get()` Get value stored on redis
|
|
17
|
+
- `.set()` Set value to redis
|
|
18
|
+
- `.del()` Delete value stored on redis
|
|
19
|
+
- `.subscribe()` Subscribe redis event
|
|
20
|
+
- `subcriber.unsubscribe()` Unsubscribe redis event
|
|
21
|
+
- `.publish()` Publish messages to subscriber
|
|
22
|
+
- `.pipeline()` Redis pipeline
|
|
23
|
+
- `.on()` Subscribe events for `connect` | `disconnect` | `error`
|
|
24
|
+
- `.off()` Unsubscribe events for `connect` | `disconnect` | `error`
|
|
25
|
+
- `.connect()` Manually connect to redis
|
|
26
|
+
- `.disconnect()` Manually disconnect from redis, will close all connections if not specify connection name
|
|
27
|
+
|
|
28
|
+
### ❤️Contributors
|
|
29
|
+
- Havea Crenata ([@crenata](https://github.com/crenata))
|
|
30
|
+
- Ghulje ([@ghulje](https://github.com/ghulje))
|
|
31
|
+
|
|
32
|
+
**Full Changelog**: https://github.com/crenata/bejibun-redis/blob/master/CHANGELOG.md
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
var _a;
|
|
2
1
|
import { defineValue, isEmpty, isNotEmpty } from "@bejibun/core";
|
|
3
2
|
import { RedisClient } from "bun";
|
|
4
3
|
import { EventEmitter } from "events";
|
|
5
4
|
import config from "../config/redis";
|
|
6
5
|
import RedisException from "../exceptions/RedisException";
|
|
7
|
-
class RedisBuilder {
|
|
6
|
+
export default class RedisBuilder {
|
|
7
|
+
static clients = {};
|
|
8
|
+
static emitter = new EventEmitter();
|
|
8
9
|
static connection(name) {
|
|
9
10
|
return {
|
|
10
11
|
del: (key) => this.del(key, name),
|
|
@@ -166,37 +167,33 @@ class RedisBuilder {
|
|
|
166
167
|
static ensureExitHooks() {
|
|
167
168
|
this.setupExitHooks();
|
|
168
169
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
170
|
+
static setupExitHooks = (() => {
|
|
171
|
+
let initialized = false;
|
|
172
|
+
return () => {
|
|
173
|
+
if (initialized)
|
|
174
|
+
return;
|
|
175
|
+
initialized = true;
|
|
176
|
+
const handleExit = async (signal) => {
|
|
177
|
+
try {
|
|
178
|
+
await RedisBuilder.disconnect();
|
|
179
|
+
console.log(`[Redis]: Disconnected on "${defineValue(signal, "exit")}".`);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
console.error("[Redis]: Error during disconnect.", error.message);
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
process.exit(0);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
process.on("exit", async () => {
|
|
189
|
+
await handleExit();
|
|
190
|
+
});
|
|
191
|
+
process.on("SIGINT", async () => {
|
|
192
|
+
await handleExit("SIGINT");
|
|
193
|
+
});
|
|
194
|
+
process.on("SIGTERM", async () => {
|
|
195
|
+
await handleExit("SIGTERM");
|
|
196
|
+
});
|
|
190
197
|
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
process.on("SIGINT", async () => {
|
|
195
|
-
await handleExit("SIGINT");
|
|
196
|
-
});
|
|
197
|
-
process.on("SIGTERM", async () => {
|
|
198
|
-
await handleExit("SIGTERM");
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
})();
|
|
202
|
-
export default RedisBuilder;
|
|
198
|
+
})();
|
|
199
|
+
}
|
package/bun.lock
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lockfileVersion": 1,
|
|
3
|
+
"workspaces": {
|
|
4
|
+
"": {
|
|
5
|
+
"name": "@bejibun/redis",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@bejibun/core": "^0.1.33",
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@types/bun": "latest",
|
|
11
|
+
"tsc-alias": "^1.8.16",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
"packages": {
|
|
16
|
+
"@bejibun/core": ["@bejibun/core@0.1.33", "", { "dependencies": { "@vinejs/vine": "^3.0.1", "chalk": "^5.6.2", "knex": "^3.1.0", "luxon": "^3.7.2", "objection": "^3.1.5", "pg": "^8.16.3" }, "peerDependencies": { "typescript": "^5" } }, "sha512-UKw+CuhbskDDv3hmixUBrCqwe4UkEubYb0UxfVR5DLdlq6+K5VrLXRxUKoA8jolFre3qvRMNM13RgQ3vLcYPgw=="],
|
|
17
|
+
|
|
18
|
+
"@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
|
|
19
|
+
|
|
20
|
+
"@nodelib/fs.stat": ["@nodelib/fs.stat@2.0.5", "", {}, "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="],
|
|
21
|
+
|
|
22
|
+
"@nodelib/fs.walk": ["@nodelib/fs.walk@1.2.8", "", { "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" } }, "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg=="],
|
|
23
|
+
|
|
24
|
+
"@poppinss/macroable": ["@poppinss/macroable@1.1.0", "", {}, "sha512-y/YKzZDuG8XrpXpM7Z1RdQpiIc0MAKyva24Ux1PB4aI7RiSI/79K8JVDcdyubriTm7vJ1LhFs8CrZpmPnx/8Pw=="],
|
|
25
|
+
|
|
26
|
+
"@types/bun": ["@types/bun@1.3.0", "", { "dependencies": { "bun-types": "1.3.0" } }, "sha512-+lAGCYjXjip2qY375xX/scJeVRmZ5cY0wyHYyCYxNcdEXrQ4AOe3gACgd4iQ8ksOslJtW4VNxBJ8llUwc3a6AA=="],
|
|
27
|
+
|
|
28
|
+
"@types/node": ["@types/node@24.7.2", "", { "dependencies": { "undici-types": "~7.14.0" } }, "sha512-/NbVmcGTP+lj5oa4yiYxxeBjRivKQ5Ns1eSZeB99ExsEQ6rX5XYU1Zy/gGxY/ilqtD4Etx9mKyrPxZRetiahhA=="],
|
|
29
|
+
|
|
30
|
+
"@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
|
|
31
|
+
|
|
32
|
+
"@types/validator": ["@types/validator@13.15.3", "", {}, "sha512-7bcUmDyS6PN3EuD9SlGGOxM77F8WLVsrwkxyWxKnxzmXoequ6c7741QBrANq6htVRGOITJ7z72mTP6Z4XyuG+Q=="],
|
|
33
|
+
|
|
34
|
+
"@vinejs/compiler": ["@vinejs/compiler@3.0.0", "", {}, "sha512-v9Lsv59nR56+bmy2p0+czjZxsLHwaibJ+SV5iK9JJfehlJMa501jUJQqqz4X/OqKXrxtE3uTQmSqjUqzF3B2mw=="],
|
|
35
|
+
|
|
36
|
+
"@vinejs/vine": ["@vinejs/vine@3.0.1", "", { "dependencies": { "@poppinss/macroable": "^1.0.4", "@types/validator": "^13.12.2", "@vinejs/compiler": "^3.0.0", "camelcase": "^8.0.0", "dayjs": "^1.11.13", "dlv": "^1.1.3", "normalize-url": "^8.0.1", "validator": "^13.12.0" } }, "sha512-ZtvYkYpZOYdvbws3uaOAvTFuvFXoQGAtmzeiXu+XSMGxi5GVsODpoI9Xu9TplEMuD/5fmAtBbKb9cQHkWkLXDQ=="],
|
|
37
|
+
|
|
38
|
+
"ajv": ["ajv@8.17.1", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g=="],
|
|
39
|
+
|
|
40
|
+
"ajv-formats": ["ajv-formats@2.1.1", "", { "dependencies": { "ajv": "^8.0.0" } }, "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA=="],
|
|
41
|
+
|
|
42
|
+
"anymatch": ["anymatch@3.1.3", "", { "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" } }, "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw=="],
|
|
43
|
+
|
|
44
|
+
"array-union": ["array-union@2.1.0", "", {}, "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw=="],
|
|
45
|
+
|
|
46
|
+
"binary-extensions": ["binary-extensions@2.3.0", "", {}, "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw=="],
|
|
47
|
+
|
|
48
|
+
"braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="],
|
|
49
|
+
|
|
50
|
+
"bun-types": ["bun-types@1.3.0", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-u8X0thhx+yJ0KmkxuEo9HAtdfgCBaM/aI9K90VQcQioAmkVp3SG3FkwWGibUFz3WdXAdcsqOcbU40lK7tbHdkQ=="],
|
|
51
|
+
|
|
52
|
+
"camelcase": ["camelcase@8.0.0", "", {}, "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA=="],
|
|
53
|
+
|
|
54
|
+
"chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
|
|
55
|
+
|
|
56
|
+
"chokidar": ["chokidar@3.6.0", "", { "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw=="],
|
|
57
|
+
|
|
58
|
+
"colorette": ["colorette@2.0.19", "", {}, "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ=="],
|
|
59
|
+
|
|
60
|
+
"commander": ["commander@9.5.0", "", {}, "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ=="],
|
|
61
|
+
|
|
62
|
+
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
|
|
63
|
+
|
|
64
|
+
"dayjs": ["dayjs@1.11.18", "", {}, "sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA=="],
|
|
65
|
+
|
|
66
|
+
"db-errors": ["db-errors@0.2.3", "", {}, "sha512-OOgqgDuCavHXjYSJoV2yGhv6SeG8nk42aoCSoyXLZUH7VwFG27rxbavU1z+VrZbZjphw5UkDQwUlD21MwZpUng=="],
|
|
67
|
+
|
|
68
|
+
"debug": ["debug@4.3.4", "", { "dependencies": { "ms": "2.1.2" } }, "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ=="],
|
|
69
|
+
|
|
70
|
+
"dir-glob": ["dir-glob@3.0.1", "", { "dependencies": { "path-type": "^4.0.0" } }, "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA=="],
|
|
71
|
+
|
|
72
|
+
"dlv": ["dlv@1.1.3", "", {}, "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA=="],
|
|
73
|
+
|
|
74
|
+
"escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
|
|
75
|
+
|
|
76
|
+
"esm": ["esm@3.2.25", "", {}, "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA=="],
|
|
77
|
+
|
|
78
|
+
"fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],
|
|
79
|
+
|
|
80
|
+
"fast-glob": ["fast-glob@3.3.3", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.8" } }, "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg=="],
|
|
81
|
+
|
|
82
|
+
"fast-uri": ["fast-uri@3.1.0", "", {}, "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA=="],
|
|
83
|
+
|
|
84
|
+
"fastq": ["fastq@1.19.1", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ=="],
|
|
85
|
+
|
|
86
|
+
"fill-range": ["fill-range@7.1.1", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="],
|
|
87
|
+
|
|
88
|
+
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
|
89
|
+
|
|
90
|
+
"function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
|
|
91
|
+
|
|
92
|
+
"get-package-type": ["get-package-type@0.1.0", "", {}, "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q=="],
|
|
93
|
+
|
|
94
|
+
"get-tsconfig": ["get-tsconfig@4.12.0", "", { "dependencies": { "resolve-pkg-maps": "^1.0.0" } }, "sha512-LScr2aNr2FbjAjZh2C6X6BxRx1/x+aTDExct/xyq2XKbYOiG5c0aK7pMsSuyc0brz3ibr/lbQiHD9jzt4lccJw=="],
|
|
95
|
+
|
|
96
|
+
"getopts": ["getopts@2.3.0", "", {}, "sha512-5eDf9fuSXwxBL6q5HX+dhDj+dslFGWzU5thZ9kNKUkcPtaPdatmUFKwHFrLb/uf/WpA4BHET+AX3Scl56cAjpA=="],
|
|
97
|
+
|
|
98
|
+
"glob-parent": ["glob-parent@5.1.2", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="],
|
|
99
|
+
|
|
100
|
+
"globby": ["globby@11.1.0", "", { "dependencies": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", "fast-glob": "^3.2.9", "ignore": "^5.2.0", "merge2": "^1.4.1", "slash": "^3.0.0" } }, "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g=="],
|
|
101
|
+
|
|
102
|
+
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
|
|
103
|
+
|
|
104
|
+
"ignore": ["ignore@5.3.2", "", {}, "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="],
|
|
105
|
+
|
|
106
|
+
"interpret": ["interpret@2.2.0", "", {}, "sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw=="],
|
|
107
|
+
|
|
108
|
+
"is-binary-path": ["is-binary-path@2.1.0", "", { "dependencies": { "binary-extensions": "^2.0.0" } }, "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw=="],
|
|
109
|
+
|
|
110
|
+
"is-core-module": ["is-core-module@2.16.1", "", { "dependencies": { "hasown": "^2.0.2" } }, "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w=="],
|
|
111
|
+
|
|
112
|
+
"is-extglob": ["is-extglob@2.1.1", "", {}, "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="],
|
|
113
|
+
|
|
114
|
+
"is-glob": ["is-glob@4.0.3", "", { "dependencies": { "is-extglob": "^2.1.1" } }, "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg=="],
|
|
115
|
+
|
|
116
|
+
"is-number": ["is-number@7.0.0", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="],
|
|
117
|
+
|
|
118
|
+
"json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
|
119
|
+
|
|
120
|
+
"knex": ["knex@3.1.0", "", { "dependencies": { "colorette": "2.0.19", "commander": "^10.0.0", "debug": "4.3.4", "escalade": "^3.1.1", "esm": "^3.2.25", "get-package-type": "^0.1.0", "getopts": "2.3.0", "interpret": "^2.2.0", "lodash": "^4.17.21", "pg-connection-string": "2.6.2", "rechoir": "^0.8.0", "resolve-from": "^5.0.0", "tarn": "^3.0.2", "tildify": "2.0.0" }, "bin": { "knex": "bin/cli.js" } }, "sha512-GLoII6hR0c4ti243gMs5/1Rb3B+AjwMOfjYm97pu0FOQa7JH56hgBxYf5WK2525ceSbBY1cjeZ9yk99GPMB6Kw=="],
|
|
121
|
+
|
|
122
|
+
"lodash": ["lodash@4.17.21", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="],
|
|
123
|
+
|
|
124
|
+
"luxon": ["luxon@3.7.2", "", {}, "sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew=="],
|
|
125
|
+
|
|
126
|
+
"merge2": ["merge2@1.4.1", "", {}, "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg=="],
|
|
127
|
+
|
|
128
|
+
"micromatch": ["micromatch@4.0.8", "", { "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" } }, "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="],
|
|
129
|
+
|
|
130
|
+
"ms": ["ms@2.1.2", "", {}, "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="],
|
|
131
|
+
|
|
132
|
+
"mylas": ["mylas@2.1.13", "", {}, "sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg=="],
|
|
133
|
+
|
|
134
|
+
"normalize-path": ["normalize-path@3.0.0", "", {}, "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="],
|
|
135
|
+
|
|
136
|
+
"normalize-url": ["normalize-url@8.1.0", "", {}, "sha512-X06Mfd/5aKsRHc0O0J5CUedwnPmnDtLF2+nq+KN9KSDlJHkPuh0JUviWjEWMe0SW/9TDdSLVPuk7L5gGTIA1/w=="],
|
|
137
|
+
|
|
138
|
+
"objection": ["objection@3.1.5", "", { "dependencies": { "ajv": "^8.17.1", "ajv-formats": "^2.1.1", "db-errors": "^0.2.3" }, "peerDependencies": { "knex": ">=1.0.1" } }, "sha512-Hx/ipAwXSuRBbOMWFKtRsAN0yITafqXtWB4OT4Z9wED7ty1h7bOnBdhLtcNus23GwLJqcMsRWdodL2p5GwlnfQ=="],
|
|
139
|
+
|
|
140
|
+
"path-parse": ["path-parse@1.0.7", "", {}, "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="],
|
|
141
|
+
|
|
142
|
+
"path-type": ["path-type@4.0.0", "", {}, "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw=="],
|
|
143
|
+
|
|
144
|
+
"pg": ["pg@8.16.3", "", { "dependencies": { "pg-connection-string": "^2.9.1", "pg-pool": "^3.10.1", "pg-protocol": "^1.10.3", "pg-types": "2.2.0", "pgpass": "1.0.5" }, "optionalDependencies": { "pg-cloudflare": "^1.2.7" }, "peerDependencies": { "pg-native": ">=3.0.1" }, "optionalPeers": ["pg-native"] }, "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw=="],
|
|
145
|
+
|
|
146
|
+
"pg-cloudflare": ["pg-cloudflare@1.2.7", "", {}, "sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg=="],
|
|
147
|
+
|
|
148
|
+
"pg-connection-string": ["pg-connection-string@2.6.2", "", {}, "sha512-ch6OwaeaPYcova4kKZ15sbJ2hKb/VP48ZD2gE7i1J+L4MspCtBMAx8nMgz7bksc7IojCIIWuEhHibSMFH8m8oA=="],
|
|
149
|
+
|
|
150
|
+
"pg-int8": ["pg-int8@1.0.1", "", {}, "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw=="],
|
|
151
|
+
|
|
152
|
+
"pg-pool": ["pg-pool@3.10.1", "", { "peerDependencies": { "pg": ">=8.0" } }, "sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg=="],
|
|
153
|
+
|
|
154
|
+
"pg-protocol": ["pg-protocol@1.10.3", "", {}, "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ=="],
|
|
155
|
+
|
|
156
|
+
"pg-types": ["pg-types@2.2.0", "", { "dependencies": { "pg-int8": "1.0.1", "postgres-array": "~2.0.0", "postgres-bytea": "~1.0.0", "postgres-date": "~1.0.4", "postgres-interval": "^1.1.0" } }, "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA=="],
|
|
157
|
+
|
|
158
|
+
"pgpass": ["pgpass@1.0.5", "", { "dependencies": { "split2": "^4.1.0" } }, "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug=="],
|
|
159
|
+
|
|
160
|
+
"picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
|
161
|
+
|
|
162
|
+
"plimit-lit": ["plimit-lit@1.6.1", "", { "dependencies": { "queue-lit": "^1.5.1" } }, "sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA=="],
|
|
163
|
+
|
|
164
|
+
"postgres-array": ["postgres-array@2.0.0", "", {}, "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA=="],
|
|
165
|
+
|
|
166
|
+
"postgres-bytea": ["postgres-bytea@1.0.0", "", {}, "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w=="],
|
|
167
|
+
|
|
168
|
+
"postgres-date": ["postgres-date@1.0.7", "", {}, "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q=="],
|
|
169
|
+
|
|
170
|
+
"postgres-interval": ["postgres-interval@1.2.0", "", { "dependencies": { "xtend": "^4.0.0" } }, "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ=="],
|
|
171
|
+
|
|
172
|
+
"queue-lit": ["queue-lit@1.5.2", "", {}, "sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw=="],
|
|
173
|
+
|
|
174
|
+
"queue-microtask": ["queue-microtask@1.2.3", "", {}, "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="],
|
|
175
|
+
|
|
176
|
+
"readdirp": ["readdirp@3.6.0", "", { "dependencies": { "picomatch": "^2.2.1" } }, "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA=="],
|
|
177
|
+
|
|
178
|
+
"rechoir": ["rechoir@0.8.0", "", { "dependencies": { "resolve": "^1.20.0" } }, "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ=="],
|
|
179
|
+
|
|
180
|
+
"require-from-string": ["require-from-string@2.0.2", "", {}, "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw=="],
|
|
181
|
+
|
|
182
|
+
"resolve": ["resolve@1.22.10", "", { "dependencies": { "is-core-module": "^2.16.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, "bin": { "resolve": "bin/resolve" } }, "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w=="],
|
|
183
|
+
|
|
184
|
+
"resolve-from": ["resolve-from@5.0.0", "", {}, "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw=="],
|
|
185
|
+
|
|
186
|
+
"resolve-pkg-maps": ["resolve-pkg-maps@1.0.0", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="],
|
|
187
|
+
|
|
188
|
+
"reusify": ["reusify@1.1.0", "", {}, "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw=="],
|
|
189
|
+
|
|
190
|
+
"run-parallel": ["run-parallel@1.2.0", "", { "dependencies": { "queue-microtask": "^1.2.2" } }, "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA=="],
|
|
191
|
+
|
|
192
|
+
"slash": ["slash@3.0.0", "", {}, "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q=="],
|
|
193
|
+
|
|
194
|
+
"split2": ["split2@4.2.0", "", {}, "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg=="],
|
|
195
|
+
|
|
196
|
+
"supports-preserve-symlinks-flag": ["supports-preserve-symlinks-flag@1.0.0", "", {}, "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="],
|
|
197
|
+
|
|
198
|
+
"tarn": ["tarn@3.0.2", "", {}, "sha512-51LAVKUSZSVfI05vjPESNc5vwqqZpbXCsU+/+wxlOrUjk2SnFTt97v9ZgQrD4YmxYW1Px6w2KjaDitCfkvgxMQ=="],
|
|
199
|
+
|
|
200
|
+
"tildify": ["tildify@2.0.0", "", {}, "sha512-Cc+OraorugtXNfs50hU9KS369rFXCfgGLpfCfvlc+Ud5u6VWmUQsOAa9HbTvheQdYnrdJqqv1e5oIqXppMYnSw=="],
|
|
201
|
+
|
|
202
|
+
"to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="],
|
|
203
|
+
|
|
204
|
+
"tsc-alias": ["tsc-alias@1.8.16", "", { "dependencies": { "chokidar": "^3.5.3", "commander": "^9.0.0", "get-tsconfig": "^4.10.0", "globby": "^11.0.4", "mylas": "^2.1.9", "normalize-path": "^3.0.0", "plimit-lit": "^1.2.6" }, "bin": { "tsc-alias": "dist/bin/index.js" } }, "sha512-QjCyu55NFyRSBAl6+MTFwplpFcnm2Pq01rR/uxfqJoLMm6X3O14KEGtaSDZpJYaE1bJBGDjD0eSuiIWPe2T58g=="],
|
|
205
|
+
|
|
206
|
+
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
207
|
+
|
|
208
|
+
"undici-types": ["undici-types@7.14.0", "", {}, "sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA=="],
|
|
209
|
+
|
|
210
|
+
"validator": ["validator@13.15.15", "", {}, "sha512-BgWVbCI72aIQy937xbawcs+hrVaN/CZ2UwutgaJ36hGqRrLNM+f5LUT/YPRbo8IV/ASeFzXszezV+y2+rq3l8A=="],
|
|
211
|
+
|
|
212
|
+
"xtend": ["xtend@4.0.2", "", {}, "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="],
|
|
213
|
+
|
|
214
|
+
"knex/commander": ["commander@10.0.1", "", {}, "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug=="],
|
|
215
|
+
|
|
216
|
+
"pg/pg-connection-string": ["pg-connection-string@2.9.1", "", {}, "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w=="],
|
|
217
|
+
}
|
|
218
|
+
}
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bejibun/redis",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
|
+
"author": "Havea Crenata <havea.crenata@gmail.com>",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/crenata/bejibun-redis.git"
|
|
8
|
+
},
|
|
9
|
+
"main": "index.js",
|
|
10
|
+
"module": "index.js",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@bejibun/core": "^0.1.33"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/bun": "latest",
|
|
16
|
+
"tsc-alias": "^1.8.16"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/crenata/bejibun-redis/issues"
|
|
20
|
+
},
|
|
4
21
|
"description": "Redis for Bejibun Framework",
|
|
22
|
+
"homepage": "https://github.com/crenata/bejibun-redis#readme",
|
|
5
23
|
"keywords": [
|
|
6
24
|
"bun",
|
|
7
25
|
"bun framework",
|
|
@@ -9,55 +27,15 @@
|
|
|
9
27
|
"bejibun",
|
|
10
28
|
"typescript"
|
|
11
29
|
],
|
|
12
|
-
"homepage": "https://github.com/crenata/bejibun-redis#readme",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/crenata/bejibun-redis/issues"
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/crenata/bejibun-redis.git"
|
|
19
|
-
},
|
|
20
30
|
"license": "MIT",
|
|
21
|
-
"author": "Havea Crenata <havea.crenata@gmail.com>",
|
|
22
|
-
"type": "module",
|
|
23
|
-
"main": "./dist/index.js",
|
|
24
|
-
"module": "./dist/index.js",
|
|
25
|
-
"types": "./dist/types/index.d.ts",
|
|
26
|
-
"exports": {
|
|
27
|
-
".": {
|
|
28
|
-
"import": "./dist/index.js",
|
|
29
|
-
"types": "./dist/types/index.d.ts"
|
|
30
|
-
},
|
|
31
|
-
"./exceptions/*": {
|
|
32
|
-
"import": "./dist/exceptions/*.js",
|
|
33
|
-
"types": "./dist/exceptions/*.d.ts"
|
|
34
|
-
},
|
|
35
|
-
"./facades/*": {
|
|
36
|
-
"import": "./dist/facades/*.js",
|
|
37
|
-
"types": "./dist/facades/*.d.ts"
|
|
38
|
-
},
|
|
39
|
-
"./types": {
|
|
40
|
-
"import": "./dist/types/index.js",
|
|
41
|
-
"types": "./dist/types/index.d.ts"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"files": [
|
|
45
|
-
"dist"
|
|
46
|
-
],
|
|
47
31
|
"scripts": {
|
|
32
|
+
"alias": "bunx tsc-alias -p tsconfig.json",
|
|
33
|
+
"copy": "cp -rf src/types dist",
|
|
34
|
+
"rsync": "rsync -a dist/ ./",
|
|
48
35
|
"clean": "rm -rf dist",
|
|
49
|
-
"build": "
|
|
36
|
+
"build": "bunx tsc -p tsconfig.json && bun run alias && bun run copy && bun run rsync && bun run clean",
|
|
50
37
|
"deploy": "bun run build && npm publish --access public"
|
|
51
38
|
},
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@types/bun": "latest",
|
|
57
|
-
"tsc-alias": "^1.8.16",
|
|
58
|
-
"typescript": "^5.9.3"
|
|
59
|
-
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"typescript": "^5"
|
|
62
|
-
}
|
|
39
|
+
"type": "module",
|
|
40
|
+
"types": "index.d.ts"
|
|
63
41
|
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type {RedisConfig, RedisPipeline, RedisSubscribe} from "@/types/redis";
|
|
2
|
+
import {defineValue, isEmpty, isNotEmpty} from "@bejibun/core";
|
|
3
|
+
import {RedisClient, RedisOptions} from "bun";
|
|
4
|
+
import {EventEmitter} from "events";
|
|
5
|
+
import config from "@/config/redis";
|
|
6
|
+
import RedisException from "@/exceptions/RedisException";
|
|
7
|
+
|
|
8
|
+
export default class RedisBuilder {
|
|
9
|
+
private static clients: Record<string, RedisClient> = {};
|
|
10
|
+
private static emitter = new EventEmitter();
|
|
11
|
+
|
|
12
|
+
public static connection(name: string): Record<string, Function> {
|
|
13
|
+
return {
|
|
14
|
+
del: (key: RedisClient.KeyLike) => this.del(key, name),
|
|
15
|
+
get: (key: RedisClient.KeyLike) => this.get(key, name),
|
|
16
|
+
pipeline: (fn: (pipe: RedisPipeline) => void) => this.pipeline(fn, name),
|
|
17
|
+
publish: (channel: string, message: any) => this.publish(channel, message, name),
|
|
18
|
+
set: (key: RedisClient.KeyLike, value: any, ttl?: number) => this.set(key, value, ttl, name),
|
|
19
|
+
subscribe: (channel: string, listener: RedisClient.StringPubSubListener) => this.subscribe(channel, listener, name),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static async connect(name?: string): Promise<RedisClient> {
|
|
24
|
+
const client = this.getClient(name);
|
|
25
|
+
await client.connect();
|
|
26
|
+
console.log(`[Redis]: Connected manually to "${defineValue(name, "default")}" connection.`);
|
|
27
|
+
this.emitter.emit("connect", defineValue(name, "default"));
|
|
28
|
+
|
|
29
|
+
return client;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static async disconnect(name?: string): Promise<void> {
|
|
33
|
+
if (isNotEmpty(name)) {
|
|
34
|
+
const client = this.clients[name as string];
|
|
35
|
+
|
|
36
|
+
if (isNotEmpty(client)) {
|
|
37
|
+
await client.close();
|
|
38
|
+
delete this.clients[name as string];
|
|
39
|
+
console.log(`[Redis]: Disconnected manually from "${name}" connection.`);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
for (const [connectionName, client] of Object.entries(this.clients)) {
|
|
43
|
+
await client.close();
|
|
44
|
+
console.log(`[Redis]: Disconnected manually from "${connectionName}" connection.`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this.clients = {};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public static async get(key: RedisClient.KeyLike, connection?: string): Promise<any> {
|
|
52
|
+
const response = await this.getClient(connection).get(key);
|
|
53
|
+
|
|
54
|
+
return this.deserialize(response);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public static async set(key: RedisClient.KeyLike, value: any, ttl?: number, connection?: string): Promise<number | "OK"> {
|
|
58
|
+
const client = this.getClient(connection);
|
|
59
|
+
const serialized = this.serialize(value);
|
|
60
|
+
|
|
61
|
+
if (ttl) return await client.expire(key, ttl);
|
|
62
|
+
|
|
63
|
+
return await client.set(key, serialized);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public static async del(key: RedisClient.KeyLike, connection?: string): Promise<number> {
|
|
67
|
+
return await this.getClient(connection).del(key);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public static async publish(channel: string, message: any, connection?: string): Promise<number> {
|
|
71
|
+
const serialized = this.serialize(message);
|
|
72
|
+
|
|
73
|
+
return await this.getClient(connection).publish(channel, serialized);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public static async subscribe(channel: string, listener: RedisClient.StringPubSubListener, connection?: string): Promise<RedisSubscribe> {
|
|
77
|
+
const cfg = this.getConfig(connection);
|
|
78
|
+
const client = this.createClient(config.default, cfg);
|
|
79
|
+
this.clients[channel] = client;
|
|
80
|
+
|
|
81
|
+
await client.subscribe(channel, (message: string, channel: string) => listener(this.deserialize(message), channel));
|
|
82
|
+
console.log(`[Redis]: Subscribed to "${channel}" channel.`);
|
|
83
|
+
|
|
84
|
+
const unsubscribe = async () => {
|
|
85
|
+
await client.unsubscribe(channel);
|
|
86
|
+
console.log(`[Redis]: Unsubscribed from "${channel}" channel.`);
|
|
87
|
+
await client.close();
|
|
88
|
+
|
|
89
|
+
return true;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
client,
|
|
94
|
+
unsubscribe: unsubscribe
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public static async pipeline(fn: (pipe: RedisPipeline) => void, connection?: string) {
|
|
99
|
+
const client = this.getClient(connection);
|
|
100
|
+
const ops: Array<Promise<any>> = [];
|
|
101
|
+
|
|
102
|
+
const pipe: RedisPipeline = {
|
|
103
|
+
del: (key: RedisClient.KeyLike): void => {
|
|
104
|
+
ops.push(client.del(key));
|
|
105
|
+
},
|
|
106
|
+
get: (key: RedisClient.KeyLike): void => {
|
|
107
|
+
ops.push(client.get(key));
|
|
108
|
+
},
|
|
109
|
+
set: (key: RedisClient.KeyLike, value: any, ttl?: number): void => {
|
|
110
|
+
const serialized = this.serialize(value);
|
|
111
|
+
|
|
112
|
+
if (isNotEmpty(ttl)) ops.push(client.expire(key, ttl as number));
|
|
113
|
+
|
|
114
|
+
ops.push(client.set(key, serialized));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
fn(pipe);
|
|
119
|
+
|
|
120
|
+
const results = await Promise.all(ops);
|
|
121
|
+
|
|
122
|
+
return results.map((result: any) => this.deserialize(result));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public static on(event: "connect" | "disconnect" | "error", listener: (...args: Array<any>) => void): void {
|
|
126
|
+
this.emitter.on(event, listener);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public static off(event: "connect" | "disconnect" | "error", listener: (...args: Array<any>) => void): void {
|
|
130
|
+
this.emitter.off(event, listener);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private static buildUrl(cfg: RedisConfig): string {
|
|
134
|
+
const url = new URL(`redis://${cfg.host}:${cfg.port}`);
|
|
135
|
+
|
|
136
|
+
if (isNotEmpty(cfg.password)) url.password = cfg.password as string;
|
|
137
|
+
if (isNotEmpty(cfg.database)) url.pathname = `/${cfg.database}`;
|
|
138
|
+
|
|
139
|
+
return url.toString();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private static createClient(name: string, cfg: RedisConfig): RedisClient {
|
|
143
|
+
const url = this.buildUrl(cfg);
|
|
144
|
+
const client = new RedisClient(url, this.getOptions(cfg));
|
|
145
|
+
|
|
146
|
+
client.onconnect = () => {
|
|
147
|
+
console.log(`[Redis]: Connected to "${name}" connection.`);
|
|
148
|
+
this.emitter.emit("connect", name);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
client.onclose = (error: Error) => {
|
|
152
|
+
console.warn(`[Redis]: Disconnected from "${name}" connection.`, error.message);
|
|
153
|
+
this.emitter.emit("disconnect", name, error);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
return client;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private static getOptions(cfg: RedisConfig): RedisOptions {
|
|
160
|
+
return {
|
|
161
|
+
autoReconnect: true,
|
|
162
|
+
maxRetries: cfg.maxRetries
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private static getConfig(name?: string): RedisConfig {
|
|
167
|
+
const connectionName = defineValue(name, config.default);
|
|
168
|
+
const connection = config.connections[connectionName];
|
|
169
|
+
|
|
170
|
+
if (isEmpty(connection)) throw new RedisException(`[Redis]: Connection "${connectionName}" not found.`);
|
|
171
|
+
|
|
172
|
+
return connection;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private static getClient(name?: string): RedisClient {
|
|
176
|
+
const connectionName = defineValue(name, config.default);
|
|
177
|
+
|
|
178
|
+
this.ensureExitHooks();
|
|
179
|
+
|
|
180
|
+
if (isEmpty(this.clients[connectionName])) {
|
|
181
|
+
const cfg = this.getConfig(connectionName);
|
|
182
|
+
this.clients[connectionName] = this.createClient(connectionName, cfg);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return this.clients[connectionName];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private static serialize(value: any): string {
|
|
189
|
+
if (isEmpty(value)) return "";
|
|
190
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
191
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
192
|
+
|
|
193
|
+
return value;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private static deserialize(value?: string | null): any {
|
|
197
|
+
if (isEmpty(value)) return null;
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
return JSON.parse(value as string);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
return value;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private static ensureExitHooks(): void {
|
|
207
|
+
this.setupExitHooks();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private static setupExitHooks = ((): Function => {
|
|
211
|
+
let initialized = false;
|
|
212
|
+
|
|
213
|
+
return (): void => {
|
|
214
|
+
if (initialized) return;
|
|
215
|
+
|
|
216
|
+
initialized = true;
|
|
217
|
+
|
|
218
|
+
const handleExit = async (signal?: string): Promise<void> => {
|
|
219
|
+
try {
|
|
220
|
+
await RedisBuilder.disconnect();
|
|
221
|
+
console.log(`[Redis]: Disconnected on "${defineValue(signal, "exit")}".`);
|
|
222
|
+
} catch (error: any) {
|
|
223
|
+
console.error("[Redis]: Error during disconnect.", error.message);
|
|
224
|
+
} finally {
|
|
225
|
+
process.exit(0);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
process.on("exit", async (): Promise<void> => {
|
|
230
|
+
await handleExit();
|
|
231
|
+
});
|
|
232
|
+
process.on("SIGINT", async (): Promise<void> => {
|
|
233
|
+
await handleExit("SIGINT");
|
|
234
|
+
});
|
|
235
|
+
process.on("SIGTERM", async (): Promise<void> => {
|
|
236
|
+
await handleExit("SIGTERM");
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
})();
|
|
240
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {defineValue} from "@bejibun/core";
|
|
2
|
+
|
|
3
|
+
export default class RedisException extends Error {
|
|
4
|
+
public code: number;
|
|
5
|
+
|
|
6
|
+
public constructor(message?: string, code?: number) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "RedisException";
|
|
9
|
+
this.code = defineValue(code, 503);
|
|
10
|
+
|
|
11
|
+
if (Error.captureStackTrace) {
|
|
12
|
+
Error.captureStackTrace(this, RedisException);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type {RedisPipeline, RedisSubscribe} from "@/types/redis";
|
|
2
|
+
import {RedisClient} from "bun";
|
|
3
|
+
import RedisBuilder from "@/builders/RedisBuilder";
|
|
4
|
+
|
|
5
|
+
export default class Redis {
|
|
6
|
+
public static connection(name: string): Record<string, Function> {
|
|
7
|
+
return RedisBuilder.connection(name);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public static async connect(name?: string): Promise<RedisClient> {
|
|
11
|
+
return RedisBuilder.connect(name);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public static async disconnect(name?: string): Promise<void> {
|
|
15
|
+
return RedisBuilder.disconnect(name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public static async get(key: RedisClient.KeyLike, connection?: string): Promise<any> {
|
|
19
|
+
return RedisBuilder.get(key, connection);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public static async set(key: RedisClient.KeyLike, value: any, ttl?: number, connection?: string): Promise<number | "OK"> {
|
|
23
|
+
return RedisBuilder.set(key, value, ttl, connection);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static async del(key: RedisClient.KeyLike, connection?: string): Promise<number> {
|
|
27
|
+
return RedisBuilder.del(key, connection);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static async publish(channel: string, message: any, connection?: string): Promise<number> {
|
|
31
|
+
return RedisBuilder.publish(channel, message, connection);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public static async subscribe(channel: string, listener: RedisClient.StringPubSubListener, connection?: string): Promise<RedisSubscribe> {
|
|
35
|
+
return RedisBuilder.subscribe(channel, listener, connection);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public static async pipeline(fn: (pipe: RedisPipeline) => void, connection?: string) {
|
|
39
|
+
return RedisBuilder.pipeline(fn, connection);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public static on(event: "connect" | "disconnect" | "error", listener: (...args: Array<any>) => void): void {
|
|
43
|
+
return RedisBuilder.on(event, listener);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public static off(event: "connect" | "disconnect" | "error", listener: (...args: Array<any>) => void): void {
|
|
47
|
+
return RedisBuilder.off(event, listener);
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"rootDir": "src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"baseUrl": ".",
|
|
13
|
+
"paths": {
|
|
14
|
+
"@/*": ["src/*"]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
package/types/index.d.ts
ADDED
package/types/redis.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type RedisConfig = {
|
|
2
|
+
host: string;
|
|
3
|
+
port: number;
|
|
4
|
+
password?: string | null;
|
|
5
|
+
database?: number;
|
|
6
|
+
maxRetries?: number;
|
|
7
|
+
};
|
|
8
|
+
export type RedisPipeline = {
|
|
9
|
+
del: (key: string) => void;
|
|
10
|
+
get: (key: string) => void;
|
|
11
|
+
set: (key: string, value: any, ttl?: number) => void;
|
|
12
|
+
};
|
|
13
|
+
export type RedisSubscribe = {
|
|
14
|
+
client: RedisClient;
|
|
15
|
+
unsubscribe: () => Promise<boolean>;
|
|
16
|
+
};
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|