@duvdu-v1/duvdu 1.1.273 → 1.1.274
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.
|
@@ -24,25 +24,15 @@ let totalConnectionsRequested = 0;
|
|
|
24
24
|
let activeConnections = 0;
|
|
25
25
|
// Parse Redis connection details
|
|
26
26
|
const getRedisConfig = () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const urlParts = host.split('://');
|
|
33
|
-
if ((_a = urlParts[1]) === null || _a === void 0 ? void 0 : _a.includes(':')) {
|
|
34
|
-
const hostParts = urlParts[1].split(':');
|
|
35
|
-
host = hostParts[0];
|
|
36
|
-
port = parseInt(hostParts[1], 10) || 6379;
|
|
37
|
-
}
|
|
38
|
-
else if (urlParts[1]) {
|
|
39
|
-
host = urlParts[1];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
27
|
+
// Get Redis configuration from environment variables
|
|
28
|
+
const host = process.env.REDIS_HOST || 'redis-11177.c9.us-east-1-2.ec2.redns.redis-cloud.com';
|
|
29
|
+
const port = parseInt(process.env.REDIS_PORT || '11177', 10);
|
|
30
|
+
const password = process.env.REDIS_PASS || 'xgThFOa24hvwyVtsiNhIJiAxfhvJCLBU';
|
|
31
|
+
console.log(`[REDIS] Connecting to Redis at ${host}:${port}`);
|
|
42
32
|
return {
|
|
43
33
|
host,
|
|
44
34
|
port,
|
|
45
|
-
password
|
|
35
|
+
password,
|
|
46
36
|
maxRetriesPerRequest: null,
|
|
47
37
|
enableReadyCheck: false,
|
|
48
38
|
retryStrategy: (times) => {
|
|
@@ -124,13 +114,13 @@ exports.getRedisClient = getRedisClient;
|
|
|
124
114
|
const redisConnection = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
115
|
try {
|
|
126
116
|
const client = (0, exports.getRedisClient)();
|
|
127
|
-
|
|
128
|
-
console.log(`[REDIS] Connection provided from pool to ${config.host}:${config.port}`);
|
|
117
|
+
console.log('[REDIS] Connection provided from pool');
|
|
129
118
|
return client;
|
|
130
119
|
}
|
|
131
120
|
catch (error) {
|
|
132
|
-
|
|
133
|
-
|
|
121
|
+
const config = getRedisConfig();
|
|
122
|
+
console.error(`[REDIS] Cannot connect to Redis: ${config.host}:${config.port}`, error);
|
|
123
|
+
throw new data_base_connections_1.DatabaseConnectionError(`Cannot connect to Redis: ${config.host}:${config.port}`);
|
|
134
124
|
}
|
|
135
125
|
});
|
|
136
126
|
exports.redisConnection = redisConnection;
|