@merkl/api 0.12.2 → 0.12.3
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,3 +1,4 @@
|
|
1
|
+
import { type RedisFunctions, type RedisModules, type RedisScripts } from "redis";
|
1
2
|
export declare const REDIS_RETRIES = 0;
|
2
3
|
export declare const REDIS_READ_TIMEOUT: number;
|
3
4
|
export declare const REDIS_WRITE_TIMEOUT = 4000;
|
@@ -308,4 +309,4 @@ export declare const redisClient: import("@redis/client").RedisClientType<{
|
|
308
309
|
RESERVE: typeof import("@redis/bloom/dist/commands/top-k/RESERVE");
|
309
310
|
reserve: typeof import("@redis/bloom/dist/commands/top-k/RESERVE");
|
310
311
|
};
|
311
|
-
} &
|
312
|
+
} & RedisModules, RedisFunctions, RedisScripts>;
|
package/dist/src/cache/redis.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { log } from "../utils/logger";
|
2
|
-
import { createClient } from "redis";
|
2
|
+
import { createClient, } from "redis";
|
3
3
|
const REDISHOST = process.env.REDISHOST || "redis";
|
4
4
|
const REDISPORT = !!process.env.REDISPORT ? Number(process.env.REDISPORT) : 6379;
|
5
5
|
const REDISPASSWORD = process.env.REDISPASSWORD || "";
|
@@ -35,15 +35,22 @@ export var TTLType;
|
|
35
35
|
*/
|
36
36
|
const redisConfig = {
|
37
37
|
url: `redis://${REDISHOST}:${REDISPORT}`,
|
38
|
-
socket: REDISHOST === "redis"
|
38
|
+
socket: REDISHOST === "redis"
|
39
|
+
? undefined
|
40
|
+
: {
|
41
|
+
tls: true,
|
42
|
+
reconnectStrategy: retries => Math.min(retries * 100, 5000),
|
43
|
+
keepAlive: 5_000,
|
44
|
+
},
|
39
45
|
password: REDISPASSWORD,
|
40
46
|
};
|
41
47
|
export const redisClient = createClient(redisConfig);
|
42
48
|
redisClient.on("error", error => {
|
43
|
-
log.error("
|
49
|
+
log.error("[REDIS]", error);
|
50
|
+
redisClient.connect().catch(() => { }); // Auto-reconnect
|
44
51
|
});
|
45
52
|
redisClient.connect();
|
46
|
-
redisClient.on("end", () => log.
|
53
|
+
redisClient.on("end", () => log.debug("[REDIS]: disconnected"));
|
47
54
|
redisClient.on("ready", () => {
|
48
|
-
log.debug("
|
55
|
+
log.debug("[REDIS]: connected");
|
49
56
|
});
|
@@ -64,7 +64,7 @@ const load = async (pendings) => {
|
|
64
64
|
log.info(`pushing ${pendings.length} pendings`);
|
65
65
|
const { updated, created } = await updatePendings({
|
66
66
|
distributionChainId: chainId,
|
67
|
-
rewardToken: pendings[0].rewardToken,
|
67
|
+
rewardToken: pendings[0].rewardToken, // sometimes undefined
|
68
68
|
campaignId,
|
69
69
|
root,
|
70
70
|
data: pendings,
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { TokenService } from "../modules/v4";
|
2
|
+
import { log } from "../utils/logger";
|
3
|
+
import { Pricer } from "../utils/pricer";
|
4
|
+
const pricer = await Pricer.load();
|
5
|
+
await pricer.update();
|
6
|
+
log.info("✅ Price cache updated successfully!");
|
7
|
+
log.info("⏳ Updating API database...");
|
8
|
+
await TokenService.updatePrices(pricer);
|
9
|
+
log.info("✅ API database updated successfully!");
|
10
|
+
process.exit(0);
|