@opengis/fastify-table 2.0.38 → 2.0.40
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/server/plugins/auth/index.d.ts.map +1 -1
- package/dist/server/plugins/auth/index.js +1 -0
- package/dist/server/plugins/redis/funcs/getRedis.d.ts +4 -2
- package/dist/server/plugins/redis/funcs/getRedis.d.ts.map +1 -1
- package/dist/server/plugins/redis/funcs/getRedis.js +11 -9
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAkB1C,iBAAS,MAAM,CAAC,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAkB1C,iBAAS,MAAM,CAAC,OAAO,EAAE,eAAe,QAsIvC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRedis.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/redis/funcs/getRedis.ts"],"names":[],"mappings":"AAOA,iBAAS,QAAQ,CAAC,EAAE,EAAE,EAAE
|
|
1
|
+
{"version":3,"file":"getRedis.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/redis/funcs/getRedis.ts"],"names":[],"mappings":"AAOA,iBAAS,QAAQ,CACf,EACE,EAAE,EACF,IAAyB,EACzB,IAAyB,GAC1B,GAAE;IACD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACH,OAsBd;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -3,21 +3,23 @@ import { Redis } from "ioredis";
|
|
|
3
3
|
// import Redis from 'ioredis';
|
|
4
4
|
import config from "../../../../config.js";
|
|
5
5
|
import redisClients from "./redisClients.js";
|
|
6
|
-
function getRedis({ db } = { db: 0 }) {
|
|
7
|
-
if (!config.redis)
|
|
6
|
+
function getRedis({ db, host = config.redis?.host, port = config.redis?.port, } = { db: 0 }) {
|
|
7
|
+
if (!config.redis && !host)
|
|
8
8
|
return null;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const key = [host, port, db].join("-");
|
|
10
|
+
if (redisClients[key]) {
|
|
11
|
+
return redisClients[key];
|
|
12
|
+
}
|
|
11
13
|
const redisConfig = {
|
|
12
14
|
db,
|
|
13
15
|
keyPrefix: `${config.db}:`,
|
|
14
|
-
host: config.redis?.host || "127.0.0.1",
|
|
15
|
-
port: config.redis?.port || 6379, // Redis port
|
|
16
|
+
host: config.redis?.host || host || "127.0.0.1",
|
|
17
|
+
port: config.redis?.port || port || 6379, // Redis port
|
|
16
18
|
family: 4, // 4 (IPv4) or 6 (IPv6)
|
|
17
19
|
closeClient: true,
|
|
18
20
|
};
|
|
19
|
-
redisClients[
|
|
20
|
-
console.log("redis connected", db);
|
|
21
|
-
return redisClients[
|
|
21
|
+
redisClients[key] = new Redis(redisConfig);
|
|
22
|
+
console.log("redis connected", db, host, port);
|
|
23
|
+
return redisClients[key];
|
|
22
24
|
}
|
|
23
25
|
export default getRedis;
|