@zorionapp/gg-core 5.0.19 → 5.0.20
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 +1 -1
- package/src/gg-redis/index.d.ts +1 -1
- package/src/gg-redis/index.js +2 -1
- package/src/gg-redis/index.js.map +1 -1
- package/src/gg-redis/redis-client.factory.d.ts +2 -0
- package/src/gg-redis/redis-client.factory.js +13 -6
- package/src/gg-redis/redis-client.factory.js.map +1 -1
package/package.json
CHANGED
package/src/gg-redis/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { redisConfig, type RedisMode } from './redis.config';
|
|
2
|
-
export { createRedisClient } from './redis-client.factory';
|
|
2
|
+
export { buildRedisClientOptions, createRedisClient, type RedisClientOptions } from './redis-client.factory';
|
package/src/gg-redis/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRedisClient = exports.redisConfig = void 0;
|
|
3
|
+
exports.createRedisClient = exports.buildRedisClientOptions = exports.redisConfig = void 0;
|
|
4
4
|
var redis_config_1 = require("./redis.config");
|
|
5
5
|
Object.defineProperty(exports, "redisConfig", { enumerable: true, get: function () { return redis_config_1.redisConfig; } });
|
|
6
6
|
var redis_client_factory_1 = require("./redis-client.factory");
|
|
7
|
+
Object.defineProperty(exports, "buildRedisClientOptions", { enumerable: true, get: function () { return redis_client_factory_1.buildRedisClientOptions; } });
|
|
7
8
|
Object.defineProperty(exports, "createRedisClient", { enumerable: true, get: function () { return redis_client_factory_1.createRedisClient; } });
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redis/index.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAApD,2GAAA,WAAW,OAAA;AACpB,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redis/index.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAApD,2GAAA,WAAW,OAAA;AACpB,+DAA6G;AAApG,+HAAA,uBAAuB,OAAA;AAAE,yHAAA,iBAAiB,OAAA"}
|
|
@@ -2,5 +2,7 @@ import { ConfigType } from '@nestjs/config';
|
|
|
2
2
|
import { default as Redis, RedisOptions } from 'ioredis';
|
|
3
3
|
import { redisConfig } from './redis.config';
|
|
4
4
|
type RedisConfigType = ConfigType<typeof redisConfig>;
|
|
5
|
+
export type RedisClientOptions = RedisOptions;
|
|
6
|
+
export declare function buildRedisClientOptions(config: RedisConfigType, options?: Partial<RedisOptions>): RedisClientOptions;
|
|
5
7
|
export declare function createRedisClient(config: RedisConfigType, options?: Partial<RedisOptions>): Redis;
|
|
6
8
|
export {};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRedisClient = void 0;
|
|
3
|
+
exports.createRedisClient = exports.buildRedisClientOptions = void 0;
|
|
4
4
|
const ioredis_1 = require("ioredis");
|
|
5
|
-
function
|
|
5
|
+
function buildRedisClientOptions(config, options) {
|
|
6
6
|
if (config.mode === 'sentinel') {
|
|
7
|
+
if (!config.sentinelHosts?.trim()) {
|
|
8
|
+
throw new Error('REDIS_SENTINEL_HOSTS is empty or invalid after parsing');
|
|
9
|
+
}
|
|
7
10
|
const sentinels = config.sentinelHosts
|
|
8
11
|
.split(';')
|
|
9
12
|
.map((entry) => entry.trim())
|
|
@@ -15,17 +18,21 @@ function createRedisClient(config, options) {
|
|
|
15
18
|
if (sentinels.length === 0) {
|
|
16
19
|
throw new Error('REDIS_SENTINEL_HOSTS is empty or invalid after parsing');
|
|
17
20
|
}
|
|
18
|
-
return
|
|
21
|
+
return {
|
|
19
22
|
sentinels,
|
|
20
23
|
name: config.sentinelMaster,
|
|
21
24
|
...options,
|
|
22
|
-
}
|
|
25
|
+
};
|
|
23
26
|
}
|
|
24
|
-
return
|
|
27
|
+
return {
|
|
25
28
|
host: config.host,
|
|
26
29
|
port: config.port,
|
|
27
30
|
...options,
|
|
28
|
-
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.buildRedisClientOptions = buildRedisClientOptions;
|
|
34
|
+
function createRedisClient(config, options) {
|
|
35
|
+
return new ioredis_1.default(buildRedisClientOptions(config, options));
|
|
29
36
|
}
|
|
30
37
|
exports.createRedisClient = createRedisClient;
|
|
31
38
|
//# sourceMappingURL=redis-client.factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis-client.factory.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redis/redis-client.factory.ts"],"names":[],"mappings":";;;AACA,qCAAyD;
|
|
1
|
+
{"version":3,"file":"redis-client.factory.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redis/redis-client.factory.ts"],"names":[],"mappings":";;;AACA,qCAAyD;AAMzD,SAAgB,uBAAuB,CACrC,MAAuB,EACvB,OAA+B;IAE/B,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa;aACnC,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;aAC5B,MAAM,CAAC,OAAO,CAAC;aACf,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtC,OAAO,EAAE,IAAI,EAAE,IAA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