dt-common-device 8.0.9 → 9.0.0
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/dist/config/config.d.ts +0 -1
- package/dist/config/config.js +2 -3
- package/dist/db/redis.js +3 -9
- package/package.json +1 -1
package/dist/config/config.d.ts
CHANGED
package/dist/config/config.js
CHANGED
|
@@ -270,12 +270,11 @@ function getDTApiKey() {
|
|
|
270
270
|
function getRedisDbHostAndPort() {
|
|
271
271
|
const host = process.env.REDIS_HOST;
|
|
272
272
|
const port = process.env.REDIS_PORT;
|
|
273
|
-
|
|
274
|
-
if (!host || !port || !nodeEnv) {
|
|
273
|
+
if (!host || !port) {
|
|
275
274
|
getConfig().LOGGER.error("REDIS_HOST and REDIS_PORT must be set in environment variables");
|
|
276
275
|
throw new Error("dt-common-device: REDIS_HOST and REDIS_PORT must be set in environment variables");
|
|
277
276
|
}
|
|
278
|
-
return { host, port: Number(port)
|
|
277
|
+
return { host, port: Number(port) };
|
|
279
278
|
}
|
|
280
279
|
/**
|
|
281
280
|
* Graceful shutdown function
|
package/dist/db/redis.js
CHANGED
|
@@ -10,16 +10,10 @@ const ioredis_1 = __importDefault(require("ioredis"));
|
|
|
10
10
|
let redisClient = null;
|
|
11
11
|
function getRedisClient() {
|
|
12
12
|
if (!redisClient) {
|
|
13
|
-
const { host, port
|
|
14
|
-
const isGreenEcs = nodeEnv === "green-ecs";
|
|
13
|
+
const { host, port } = (0, config_1.getRedisDbHostAndPort)();
|
|
15
14
|
redisClient = new ioredis_1.default({
|
|
16
15
|
host,
|
|
17
16
|
port,
|
|
18
|
-
tls: isGreenEcs
|
|
19
|
-
? {
|
|
20
|
-
rejectUnauthorized: false, // required for AWS ElastiCache TLS
|
|
21
|
-
}
|
|
22
|
-
: undefined, // no TLS for dev/QA/UAT
|
|
23
17
|
lazyConnect: true,
|
|
24
18
|
enableReadyCheck: false,
|
|
25
19
|
connectTimeout: 10000,
|
|
@@ -29,10 +23,10 @@ function getRedisClient() {
|
|
|
29
23
|
console.error("Redis error:", error);
|
|
30
24
|
});
|
|
31
25
|
redisClient.on("connect", () => {
|
|
32
|
-
console.log("
|
|
26
|
+
console.log(" Redis connected successfully");
|
|
33
27
|
});
|
|
34
28
|
redisClient.on("ready", () => {
|
|
35
|
-
console.log("
|
|
29
|
+
console.log(" Redis ready for operations");
|
|
36
30
|
});
|
|
37
31
|
}
|
|
38
32
|
return redisClient;
|