@bejibun/redis 0.1.32 → 0.1.33

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 CHANGED
@@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ---
5
5
 
6
+ ## [v0.1.33](https://github.com/crenata/bejibun-redis/compare/v0.1.30...v0.1.33) - 2025-11-09
7
+
8
+ ### 🩹 Fixes
9
+ - Fix redis configuration
10
+
11
+ ### 📖 Changes
12
+
13
+ ### ❤️Contributors
14
+ - Havea Crenata ([@crenata](https://github.com/crenata))
15
+
16
+ **Full Changelog**: https://github.com/crenata/bejibun-redis/blob/master/CHANGELOG.md
17
+
18
+ ---
19
+
6
20
  ## [v0.1.30](https://github.com/crenata/bejibun-redis/compare/v0.1.29...v0.1.30) - 2025-10-22
7
21
 
8
22
  ### 🩹 Fixes
@@ -13,6 +13,7 @@ export default class RedisBuilder {
13
13
  static pipeline(fn: (pipe: RedisPipeline) => void, connection?: string): Promise<any[]>;
14
14
  static on(event: "connect" | "disconnect" | "error", listener: (...args: Array<any>) => void): void;
15
15
  static off(event: "connect" | "disconnect" | "error", listener: (...args: Array<any>) => void): void;
16
+ private static get config();
16
17
  private static buildUrl;
17
18
  private static createClient;
18
19
  private static getOptions;
@@ -1,7 +1,9 @@
1
+ import App from "@bejibun/app";
1
2
  import Logger from "@bejibun/logger";
2
3
  import { defineValue, isEmpty, isNotEmpty } from "@bejibun/utils";
3
4
  import { EventEmitter } from "events";
4
- import config from "../config/redis";
5
+ import fs from "fs";
6
+ import RedisConf from "../config/redis";
5
7
  import RedisException from "../exceptions/RedisException";
6
8
  export default class RedisBuilder {
7
9
  static clients = {};
@@ -60,7 +62,7 @@ export default class RedisBuilder {
60
62
  }
61
63
  static async subscribe(channel, listener, connection) {
62
64
  const cfg = this.getConfig(connection);
63
- const client = this.createClient(config.default, cfg);
65
+ const client = this.createClient(this.config.default, cfg);
64
66
  this.clients[channel] = client;
65
67
  await client.subscribe(channel, (message, channel) => listener(this.deserialize(message), channel));
66
68
  Logger.setContext("Redis").info(`Subscribed to "${channel}" channel.`);
@@ -102,6 +104,15 @@ export default class RedisBuilder {
102
104
  static off(event, listener) {
103
105
  this.emitter.off(event, listener);
104
106
  }
107
+ static get config() {
108
+ let config;
109
+ const configPath = App.Path.configPath("redis.ts");
110
+ if (fs.existsSync(configPath))
111
+ config = require(configPath).default;
112
+ else
113
+ config = RedisConf;
114
+ return config;
115
+ }
105
116
  static buildUrl(cfg) {
106
117
  const url = new URL(`redis://${cfg.host}:${cfg.port}`);
107
118
  if (isNotEmpty(cfg.password))
@@ -130,14 +141,14 @@ export default class RedisBuilder {
130
141
  };
131
142
  }
132
143
  static getConfig(name) {
133
- const connectionName = defineValue(name, config.default);
134
- const connection = config.connections[connectionName];
144
+ const connectionName = defineValue(name, this.config.default);
145
+ const connection = this.config.connections[connectionName];
135
146
  if (isEmpty(connection))
136
147
  throw new RedisException(`Connection "${connectionName}" not found.`);
137
148
  return connection;
138
149
  }
139
150
  static getClient(name) {
140
- const connectionName = defineValue(name, config.default);
151
+ const connectionName = defineValue(name, this.config.default);
141
152
  this.ensureExitHooks();
142
153
  if (isEmpty(this.clients[connectionName])) {
143
154
  const cfg = this.getConfig(connectionName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bejibun/redis",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "author": "Havea Crenata <havea.crenata@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",