@duvdu-v1/duvdu 1.1.28 → 1.1.29
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,9 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// import RedisStore from 'connect-redis';
|
|
3
|
+
// import { createClient } from 'redis';
|
|
2
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
6
|
};
|
|
5
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
8
|
exports.sessionStore = exports.redisConnection = void 0;
|
|
9
|
+
// import { DatabaseConnectionError } from '../errors/data-base-connections';
|
|
10
|
+
// export const redisConnection = (url: string , password:string , port:number) => {
|
|
11
|
+
// const client = createClient({
|
|
12
|
+
// password,
|
|
13
|
+
// socket:{
|
|
14
|
+
// host:url,
|
|
15
|
+
// port
|
|
16
|
+
// }
|
|
17
|
+
// });
|
|
18
|
+
// client
|
|
19
|
+
// .connect()
|
|
20
|
+
// .then(() => console.log(`redis connected in : ${url}`))
|
|
21
|
+
// .catch(() => {
|
|
22
|
+
// throw new DatabaseConnectionError(`cannot connect to redis : ${url}`);
|
|
23
|
+
// });
|
|
24
|
+
// return client;
|
|
25
|
+
// };
|
|
26
|
+
// export const sessionStore = (url: string , password:string , port:number) => new RedisStore({ client: redisConnection(url, password , port) });
|
|
7
27
|
const connect_redis_1 = __importDefault(require("connect-redis"));
|
|
8
28
|
const redis_1 = require("redis");
|
|
9
29
|
const data_base_connections_1 = require("../errors/data-base-connections");
|
|
@@ -12,17 +32,21 @@ const redisConnection = (url, password, port) => {
|
|
|
12
32
|
password,
|
|
13
33
|
socket: {
|
|
14
34
|
host: url,
|
|
15
|
-
port
|
|
35
|
+
port,
|
|
16
36
|
}
|
|
17
37
|
});
|
|
18
|
-
client
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
38
|
+
client.on('connect', () => {
|
|
39
|
+
console.log(`Redis connected to ${url}:${port}`);
|
|
40
|
+
});
|
|
41
|
+
client.on('error', (err) => {
|
|
42
|
+
console.error(`Redis connection error: ${err}`);
|
|
43
|
+
throw new data_base_connections_1.DatabaseConnectionError(`Cannot connect to Redis: ${err}`);
|
|
23
44
|
});
|
|
24
45
|
return client;
|
|
25
46
|
};
|
|
26
47
|
exports.redisConnection = redisConnection;
|
|
27
|
-
const sessionStore = (url, password, port) =>
|
|
48
|
+
const sessionStore = (url, password, port) => {
|
|
49
|
+
const client = (0, exports.redisConnection)(url, password, port);
|
|
50
|
+
return new connect_redis_1.default({ client });
|
|
51
|
+
};
|
|
28
52
|
exports.sessionStore = sessionStore;
|