@duvdu-v1/duvdu 1.1.261 → 1.1.263
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import RedisStore from 'connect-redis';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getRedisClient: () => import("@redis/client").RedisClientType<{
|
|
3
3
|
graph: {
|
|
4
4
|
CONFIG_GET: typeof import("@redis/graph/dist/commands/CONFIG_GET");
|
|
5
5
|
configGet: typeof import("@redis/graph/dist/commands/CONFIG_GET");
|
|
@@ -580,3 +580,4 @@ export declare const redisConnection: (url: string, password: string) => Promise
|
|
|
580
580
|
};
|
|
581
581
|
} & import("redis").RedisModules, import("redis").RedisFunctions, import("redis").RedisScripts>>;
|
|
582
582
|
export declare const sessionStore: (url: string, password: string) => Promise<RedisStore>;
|
|
583
|
+
export declare const cleanupRedis: () => Promise<void>;
|
|
@@ -12,19 +12,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.sessionStore = exports.redisConnection = exports.
|
|
15
|
+
exports.cleanupRedis = exports.sessionStore = exports.redisConnection = exports.getRedisClient = void 0;
|
|
16
16
|
const connect_redis_1 = __importDefault(require("connect-redis"));
|
|
17
17
|
const redis_1 = require("redis");
|
|
18
18
|
const data_base_connections_1 = require("../errors/data-base-connections");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
let redisClient = null;
|
|
20
|
+
const getRedisClient = () => {
|
|
21
|
+
if (!redisClient) {
|
|
22
|
+
redisClient = (0, redis_1.createClient)({
|
|
23
|
+
url: process.env.REDIS_HOST,
|
|
24
|
+
password: process.env.REDIS_PASS,
|
|
25
|
+
});
|
|
26
|
+
// Set a higher limit for event listeners
|
|
27
|
+
redisClient.setMaxListeners(20);
|
|
28
|
+
}
|
|
29
|
+
return redisClient;
|
|
30
|
+
};
|
|
31
|
+
exports.getRedisClient = getRedisClient;
|
|
23
32
|
const redisConnection = (url, password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
33
|
try {
|
|
25
|
-
|
|
34
|
+
const client = (0, exports.getRedisClient)();
|
|
35
|
+
if (!client.isOpen) {
|
|
36
|
+
yield client.connect();
|
|
37
|
+
}
|
|
26
38
|
console.log(`Redis connected in : ${url}`);
|
|
27
|
-
return
|
|
39
|
+
return client;
|
|
28
40
|
}
|
|
29
41
|
catch (error) {
|
|
30
42
|
console.error(`Cannot connect to Redis: ${url}`, error);
|
|
@@ -33,6 +45,14 @@ const redisConnection = (url, password) => __awaiter(void 0, void 0, void 0, fun
|
|
|
33
45
|
});
|
|
34
46
|
exports.redisConnection = redisConnection;
|
|
35
47
|
const sessionStore = (url, password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
|
|
48
|
+
const client = (0, exports.getRedisClient)();
|
|
49
|
+
return new connect_redis_1.default({ client });
|
|
37
50
|
});
|
|
38
51
|
exports.sessionStore = sessionStore;
|
|
52
|
+
const cleanupRedis = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
if (redisClient) {
|
|
54
|
+
yield redisClient.quit();
|
|
55
|
+
redisClient = null;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
exports.cleanupRedis = cleanupRedis;
|