@windrun-huaiin/backend-core 13.0.0 → 14.1.0
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/_virtual/index.js +7 -3
- package/dist/_virtual/index.mjs +5 -3
- package/dist/_virtual/index2.js +2 -6
- package/dist/_virtual/index2.mjs +2 -6
- package/dist/index.js +3 -1
- package/dist/index.mjs +2 -2
- package/dist/lib/index.js +3 -1
- package/dist/lib/index.mjs +2 -2
- package/dist/lib/stripe-config.d.ts +1 -1
- package/dist/lib/stripe-config.d.ts.map +1 -1
- package/dist/lib/stripe-config.js +25 -16
- package/dist/lib/stripe-config.mjs +25 -16
- package/dist/lib/upstash/qstash.d.ts.map +1 -1
- package/dist/lib/upstash/qstash.js +66 -62
- package/dist/lib/upstash/qstash.mjs +67 -63
- package/dist/lib/upstash/redis-counter.d.ts.map +1 -1
- package/dist/lib/upstash/redis-counter.js +9 -24
- package/dist/lib/upstash/redis-counter.mjs +10 -25
- package/dist/lib/upstash/redis-favorite.d.ts.map +1 -1
- package/dist/lib/upstash/redis-favorite.js +22 -36
- package/dist/lib/upstash/redis-favorite.mjs +23 -37
- package/dist/lib/upstash/redis-like.d.ts.map +1 -1
- package/dist/lib/upstash/redis-like.js +22 -36
- package/dist/lib/upstash/redis-like.mjs +23 -37
- package/dist/lib/upstash/redis-lock.d.ts.map +1 -1
- package/dist/lib/upstash/redis-lock.js +22 -38
- package/dist/lib/upstash/redis-lock.mjs +23 -39
- package/dist/lib/upstash/redis-structures.d.ts.map +1 -1
- package/dist/lib/upstash/redis-structures.js +77 -113
- package/dist/lib/upstash/redis-structures.mjs +78 -114
- package/dist/lib/upstash-config.d.ts +9 -1
- package/dist/lib/upstash-config.d.ts.map +1 -1
- package/dist/lib/upstash-config.js +221 -27
- package/dist/lib/upstash-config.mjs +220 -28
- package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.js → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.js} +897 -468
- package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.mjs → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.mjs} +895 -468
- package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.js → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.js} +657 -40
- package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.mjs → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.mjs} +657 -41
- package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.js +6 -5
- package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.mjs +2 -2
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.js +1 -1
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs +1 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.js +6 -6
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.js +1 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.js +2 -2
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.js +1 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.js +7 -5
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js +4 -2
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.js +1 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.js +6 -4
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.js +6 -4
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.js +7 -5
- package/dist/services/stripe/webhook-handler.js +4 -2
- package/dist/services/stripe/webhook-handler.mjs +3 -1
- package/package.json +5 -5
- package/src/lib/stripe-config.ts +27 -15
- package/src/lib/upstash/qstash.ts +64 -62
- package/src/lib/upstash/redis-counter.ts +10 -26
- package/src/lib/upstash/redis-favorite.ts +23 -42
- package/src/lib/upstash/redis-like.ts +23 -42
- package/src/lib/upstash/redis-lock.ts +23 -49
- package/src/lib/upstash/redis-structures.ts +82 -131
- package/src/lib/upstash-config.ts +231 -24
- package/src/services/stripe/webhook-handler.ts +3 -1
- package/dist/_virtual/index3.js +0 -5
- package/dist/_virtual/index3.mjs +0 -3
- package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.js +0 -191
- package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.mjs +0 -189
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.js +0 -54
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.mjs +0 -51
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.js +0 -44
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.mjs +0 -35
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.js +0 -31
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.mjs +0 -18
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.js +0 -587
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.mjs +0 -527
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.js +0 -447
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.mjs +0 -399
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.js +0 -245
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.mjs +0 -232
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.js +0 -68
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.mjs +0 -62
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.js +0 -39
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.mjs +0 -37
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.js +0 -80
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.mjs +0 -75
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.js +0 -101
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.mjs +0 -86
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.js +0 -102
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.mjs +0 -76
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.js +0 -56
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.mjs +0 -52
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.js +0 -1205
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.mjs +0 -1157
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.js +0 -407
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.mjs +0 -374
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.js +0 -9
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.mjs +0 -7
|
@@ -1,50 +1,242 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __awaiter } from '../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs';
|
|
2
|
+
import { Redis as Redis2 } from '../node_modules/.pnpm/@upstash_redis@1.37.0/node_modules/@upstash/redis/nodejs.mjs';
|
|
3
|
+
import { Client } from '../node_modules/.pnpm/@upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.mjs';
|
|
3
4
|
|
|
4
5
|
let cachedRedis = null;
|
|
5
6
|
let cachedQstash = null;
|
|
6
|
-
let
|
|
7
|
-
let
|
|
7
|
+
let redisInitPromise = null;
|
|
8
|
+
let qstashInitPromise = null;
|
|
9
|
+
let redisWarnedMissingEnv = false;
|
|
10
|
+
let redisWarnedInvalidEnv = false;
|
|
11
|
+
let redisWarnedInitError = false;
|
|
12
|
+
let redisWarnedHealthCheck = false;
|
|
13
|
+
let redisWarnedHealthSchedule = false;
|
|
14
|
+
let qstashWarnedMissingEnv = false;
|
|
15
|
+
let qstashWarnedInitError = false;
|
|
16
|
+
let qstashWarnedHealthCheck = false;
|
|
17
|
+
let qstashWarnedHealthSchedule = false;
|
|
18
|
+
let redisHealthTimer = null;
|
|
19
|
+
let qstashHealthTimer = null;
|
|
20
|
+
const isNonEmpty = (value) => typeof value === 'string' && value.trim().length > 0;
|
|
21
|
+
const isValidUrl = (value) => {
|
|
22
|
+
try {
|
|
23
|
+
const parsed = new URL(value);
|
|
24
|
+
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
|
|
25
|
+
}
|
|
26
|
+
catch (_a) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const parseMinutes = (value, fallback) => {
|
|
31
|
+
if (!isNonEmpty(value)) {
|
|
32
|
+
return fallback;
|
|
33
|
+
}
|
|
34
|
+
const minutes = Number(value);
|
|
35
|
+
if (!Number.isFinite(minutes) || minutes <= 0) {
|
|
36
|
+
return fallback;
|
|
37
|
+
}
|
|
38
|
+
return minutes;
|
|
39
|
+
};
|
|
40
|
+
const getRedisHealthIntervalMinutes = () => parseMinutes(process.env.UPSTASH_REDIS_HEALTHCHECK_INTERVAL_MINUTES, 10);
|
|
41
|
+
const getQstashHealthIntervalMinutes = () => parseMinutes(process.env.UPSTASH_QSTASH_HEALTHCHECK_INTERVAL_MINUTES, 10);
|
|
42
|
+
const getQstashHealthcheckUrl = () => { var _a; return (_a = process.env.UPSTASH_QSTASH_HEALTHCHECK_URL) !== null && _a !== void 0 ? _a : 'https://qstash.upstash.io/v2/topics'; };
|
|
43
|
+
const scheduleRedisHealthCheck = () => {
|
|
44
|
+
if (redisHealthTimer || !cachedRedis) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const delayMs = getRedisHealthIntervalMinutes() * 60000;
|
|
48
|
+
redisHealthTimer = setTimeout(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
redisHealthTimer = null;
|
|
50
|
+
if (!cachedRedis) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
yield cachedRedis.ping();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
cachedRedis = null;
|
|
58
|
+
if (!redisWarnedHealthCheck) {
|
|
59
|
+
redisWarnedHealthCheck = true;
|
|
60
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
61
|
+
console.warn(`[Upstash Config] Redis health check failed: ${message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
try {
|
|
66
|
+
scheduleRedisHealthCheck();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (!redisWarnedHealthSchedule) {
|
|
70
|
+
redisWarnedHealthSchedule = true;
|
|
71
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
72
|
+
console.warn(`[Upstash Config] Redis health check schedule failed: ${message}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}), delayMs);
|
|
77
|
+
};
|
|
78
|
+
const checkQstashHealth = (token) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
const response = yield fetch(getQstashHealthcheckUrl(), {
|
|
80
|
+
method: 'GET',
|
|
81
|
+
headers: {
|
|
82
|
+
Authorization: `Bearer ${token}`,
|
|
83
|
+
},
|
|
84
|
+
cache: 'no-store',
|
|
85
|
+
});
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
throw new Error(`HTTP ${response.status}`);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const scheduleQstashHealthCheck = (token) => {
|
|
91
|
+
if (qstashHealthTimer || !cachedQstash) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const delayMs = getQstashHealthIntervalMinutes() * 60000;
|
|
95
|
+
qstashHealthTimer = setTimeout(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
qstashHealthTimer = null;
|
|
97
|
+
if (!cachedQstash) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
yield checkQstashHealth(token);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
cachedQstash = null;
|
|
105
|
+
if (!qstashWarnedHealthCheck) {
|
|
106
|
+
qstashWarnedHealthCheck = true;
|
|
107
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
108
|
+
console.warn(`[Upstash Config] QStash health check failed: ${message}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
try {
|
|
113
|
+
scheduleQstashHealthCheck(token);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (!qstashWarnedHealthSchedule) {
|
|
117
|
+
qstashWarnedHealthSchedule = true;
|
|
118
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
119
|
+
console.warn(`[Upstash Config] QStash health check schedule failed: ${message}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}), delayMs);
|
|
124
|
+
};
|
|
8
125
|
/**
|
|
9
|
-
* Get the Upstash Redis client. Returns null when required env vars are missing.
|
|
126
|
+
* Get the Upstash Redis client. Returns null when required env vars are missing/invalid.
|
|
127
|
+
*
|
|
128
|
+
* Singleton semantics:
|
|
129
|
+
* - read-through cached instance only
|
|
10
130
|
*/
|
|
11
131
|
const getRedis = () => {
|
|
132
|
+
return cachedRedis;
|
|
133
|
+
};
|
|
134
|
+
const ensureRedis = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
135
|
if (cachedRedis) {
|
|
13
136
|
return cachedRedis;
|
|
14
137
|
}
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
redisInitAttempted = true;
|
|
19
|
-
const { UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN } = process.env;
|
|
20
|
-
if (!UPSTASH_REDIS_REST_URL || !UPSTASH_REDIS_REST_TOKEN) {
|
|
21
|
-
console.warn('[Upstash Config] Redis Missed configration UPSTASH_REDIS_REST_URL or UPSTASH_REDIS_REST_TOKEN, then disabled');
|
|
22
|
-
return null;
|
|
138
|
+
if (redisInitPromise) {
|
|
139
|
+
return redisInitPromise;
|
|
23
140
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
141
|
+
redisInitPromise = (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
+
const { UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN } = process.env;
|
|
143
|
+
if (!isNonEmpty(UPSTASH_REDIS_REST_URL) || !isNonEmpty(UPSTASH_REDIS_REST_TOKEN)) {
|
|
144
|
+
if (!redisWarnedMissingEnv) {
|
|
145
|
+
redisWarnedMissingEnv = true;
|
|
146
|
+
console.warn('[Upstash Config] Redis disabled: missing UPSTASH_REDIS_REST_URL or UPSTASH_REDIS_REST_TOKEN');
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
if (!isValidUrl(UPSTASH_REDIS_REST_URL)) {
|
|
151
|
+
if (!redisWarnedInvalidEnv) {
|
|
152
|
+
redisWarnedInvalidEnv = true;
|
|
153
|
+
console.warn('[Upstash Config] Redis disabled: UPSTASH_REDIS_REST_URL is not a valid URL');
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const client = new Redis2({
|
|
159
|
+
url: UPSTASH_REDIS_REST_URL,
|
|
160
|
+
token: UPSTASH_REDIS_REST_TOKEN,
|
|
161
|
+
});
|
|
162
|
+
yield client.ping();
|
|
163
|
+
cachedRedis = client;
|
|
164
|
+
scheduleRedisHealthCheck();
|
|
165
|
+
return cachedRedis;
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (!redisWarnedInitError) {
|
|
169
|
+
redisWarnedInitError = true;
|
|
170
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
171
|
+
console.warn(`[Upstash Config] Redis init failed: ${message}`);
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
redisInitPromise = null;
|
|
177
|
+
}
|
|
178
|
+
}))();
|
|
179
|
+
return redisInitPromise;
|
|
180
|
+
});
|
|
30
181
|
/**
|
|
31
182
|
* Get the Upstash QStash client. Returns null when required env vars are missing.
|
|
183
|
+
*
|
|
184
|
+
* Singleton semantics:
|
|
185
|
+
* - read-through cached instance only
|
|
32
186
|
*/
|
|
33
187
|
const getQstash = () => {
|
|
188
|
+
return cachedQstash;
|
|
189
|
+
};
|
|
190
|
+
const ensureQstash = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
191
|
if (cachedQstash) {
|
|
35
192
|
return cachedQstash;
|
|
36
193
|
}
|
|
37
|
-
if (
|
|
194
|
+
if (qstashInitPromise) {
|
|
195
|
+
return qstashInitPromise;
|
|
196
|
+
}
|
|
197
|
+
qstashInitPromise = (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
198
|
+
const { QSTASH_TOKEN } = process.env;
|
|
199
|
+
if (!isNonEmpty(QSTASH_TOKEN)) {
|
|
200
|
+
if (!qstashWarnedMissingEnv) {
|
|
201
|
+
qstashWarnedMissingEnv = true;
|
|
202
|
+
console.warn('[Upstash Config] QStash disabled: missing QSTASH_TOKEN');
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const client = new Client({ token: QSTASH_TOKEN });
|
|
208
|
+
yield checkQstashHealth(QSTASH_TOKEN);
|
|
209
|
+
cachedQstash = client;
|
|
210
|
+
scheduleQstashHealthCheck(QSTASH_TOKEN);
|
|
211
|
+
return cachedQstash;
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
if (!qstashWarnedInitError) {
|
|
215
|
+
qstashWarnedInitError = true;
|
|
216
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
217
|
+
console.warn(`[Upstash Config] QStash init failed: ${message}`);
|
|
218
|
+
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
finally {
|
|
222
|
+
qstashInitPromise = null;
|
|
223
|
+
}
|
|
224
|
+
}))();
|
|
225
|
+
return qstashInitPromise;
|
|
226
|
+
});
|
|
227
|
+
const withRedis = (fn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
228
|
+
const redis = yield ensureRedis();
|
|
229
|
+
if (!redis) {
|
|
38
230
|
return null;
|
|
39
231
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
232
|
+
return fn(redis);
|
|
233
|
+
});
|
|
234
|
+
const withQstash = (fn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
235
|
+
const qstash = yield ensureQstash();
|
|
236
|
+
if (!qstash) {
|
|
44
237
|
return null;
|
|
45
238
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
239
|
+
return fn(qstash);
|
|
240
|
+
});
|
|
49
241
|
|
|
50
|
-
export { getQstash, getRedis };
|
|
242
|
+
export { getQstash, getRedis, withQstash, withRedis };
|