@withwiz/toolkit 0.4.0 → 0.4.1
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/auth/core/jwt/cookie.js +4 -1
- package/dist/auth/core/jwt/index.js +4 -1
- package/dist/auth/index.js +7 -4
- package/dist/cache/cache-config.d.ts +0 -32
- package/dist/cache/cache-config.js +4 -4
- package/dist/cache/cache-defaults.d.ts +2 -28
- package/dist/cache/cache-defaults.js +1 -1
- package/dist/cache/cache-env.js +3 -3
- package/dist/cache/cache-factory.js +10 -10
- package/dist/cache/cache-invalidation.js +10 -10
- package/dist/cache/cache-redis.js +4 -4
- package/dist/cache/cache-wrapper.js +10 -10
- package/dist/cache/cache.js +16 -20
- package/dist/cache/config.d.ts +0 -8
- package/dist/cache/config.js +2 -2
- package/dist/cache/hybrid-cache-manager.js +5 -5
- package/dist/cache/index.d.ts +0 -1
- package/dist/cache/index.js +16 -20
- package/dist/cache/noop-cache-manager.d.ts +2 -2
- package/dist/cache/noop-cache-manager.js +5 -5
- package/dist/cache/redis-cache-manager.d.ts +2 -2
- package/dist/cache/redis-cache-manager.js +5 -5
- package/dist/{chunk-TO5CMMQC.js → chunk-2VMTIYLX.js} +2 -15
- package/dist/{chunk-WNF2RKFA.js → chunk-3J7FDOCU.js} +9 -9
- package/dist/{chunk-IQQKKUAV.js → chunk-57W32BFZ.js} +4 -30
- package/dist/chunk-7LJWRKDT.js +45 -0
- package/dist/{chunk-XI4MRH5P.js → chunk-BJLLMVWW.js} +11 -39
- package/dist/{chunk-JLLMTTQ4.js → chunk-C4TSQUFA.js} +0 -7
- package/dist/{chunk-FDRIFPG6.js → chunk-CRWMULHR.js} +4 -4
- package/dist/{chunk-SV7X6HEN.js → chunk-FUDEEQR3.js} +5 -5
- package/dist/{chunk-VF4EVAMV.js → chunk-GFAD4UAT.js} +1 -1
- package/dist/{chunk-7IN4WRSO.js → chunk-GGSFZP6T.js} +9 -9
- package/dist/{chunk-BYCFXGQL.js → chunk-N3TAGJHR.js} +2 -2
- package/dist/{chunk-AJLUPYCQ.js → chunk-N4D6OPPP.js} +16 -6
- package/dist/{chunk-KZUBO2IL.js → chunk-NQQU6UFE.js} +4 -4
- package/dist/{chunk-TFD3DSM2.js → chunk-UCIUAZQT.js} +14 -18
- package/dist/{chunk-AXCB7SKY.js → chunk-X5RMDLLM.js} +15 -15
- package/dist/{chunk-RWVGJUON.js → chunk-YSUL3SLC.js} +3 -3
- package/dist/{chunk-OIVXOT2X.js → chunk-YUBXS7YI.js} +2 -3
- package/dist/{chunk-VDXB5DCY.js → chunk-ZRDPJORV.js} +0 -10
- package/dist/constants/index.js +8 -10
- package/dist/constants/pagination.d.ts +0 -5
- package/dist/constants/pagination.js +1 -1
- package/dist/constants/security.d.ts +0 -6
- package/dist/constants/security.js +1 -3
- package/dist/constants/validation.d.ts +1 -3
- package/dist/initialize.js +4 -4
- package/dist/middleware/auth.js +1 -1
- package/dist/middleware/index.js +5 -5
- package/dist/middleware/rate-limit.d.ts +1 -1
- package/dist/middleware/wrappers.js +3 -3
- package/dist/system/environment.js +3 -3
- package/dist/system/health-check.js +4 -4
- package/dist/system/index.js +5 -5
- package/dist/types/env.d.ts +2 -13
- package/dist/types/qr-code.d.ts +1 -1
- package/dist/utils/cors.d.ts +6 -4
- package/dist/utils/cors.js +1 -1
- package/dist/utils/error-message-formatter.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/optimistic-lock.d.ts +4 -4
- package/package.json +1 -1
- package/dist/cache/cache-keys-legacy.d.ts +0 -35
- package/dist/cache/cache-keys-legacy.js +0 -7
- package/dist/chunk-JBCDEAMW.js +0 -35
- package/dist/chunk-O7CK3CKJ.js +0 -84
- package/dist/{chunk-YP5SAHAP.js → chunk-5WP57PJK.js} +3 -3
- /package/dist/{chunk-QMCOX3DP.js → chunk-EBUEBEJX.js} +0 -0
|
@@ -51,10 +51,9 @@ function getBaseUrl() {
|
|
|
51
51
|
}
|
|
52
52
|
} catch (e) {
|
|
53
53
|
}
|
|
54
|
-
return "
|
|
54
|
+
return "";
|
|
55
55
|
}
|
|
56
56
|
function getAllowedOrigins() {
|
|
57
|
-
var _a;
|
|
58
57
|
const origins = /* @__PURE__ */ new Set();
|
|
59
58
|
try {
|
|
60
59
|
const middlewareCorsConfig = getCorsConfig();
|
|
@@ -62,25 +61,13 @@ function getAllowedOrigins() {
|
|
|
62
61
|
} catch (e) {
|
|
63
62
|
}
|
|
64
63
|
const baseUrl = getBaseUrl();
|
|
65
|
-
if (baseUrl
|
|
64
|
+
if (baseUrl) {
|
|
66
65
|
const extractedDomains = extractDomainsFromUrl(baseUrl);
|
|
67
66
|
extractedDomains.forEach((domain) => origins.add(domain));
|
|
68
67
|
}
|
|
69
68
|
if (globalCorsConfig.additionalOrigins) {
|
|
70
69
|
globalCorsConfig.additionalOrigins.forEach((origin) => origins.add(origin));
|
|
71
70
|
}
|
|
72
|
-
let isDev = (_a = globalCorsConfig.isDevelopment) != null ? _a : false;
|
|
73
|
-
if (!isDev) {
|
|
74
|
-
try {
|
|
75
|
-
isDev = getCommonConfig().nodeEnv === "development";
|
|
76
|
-
} catch (e) {
|
|
77
|
-
isDev = false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (isDev) {
|
|
81
|
-
origins.add("http://localhost:3000");
|
|
82
|
-
origins.add("http://127.0.0.1:3000");
|
|
83
|
-
}
|
|
84
71
|
return Array.from(origins).filter(Boolean);
|
|
85
72
|
}
|
|
86
73
|
function isOriginAllowed(origin) {
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
getAuthConfig
|
|
9
9
|
} from "./chunk-OZE5KUS3.js";
|
|
10
|
+
import {
|
|
11
|
+
getResolvedCacheConfig
|
|
12
|
+
} from "./chunk-UCIUAZQT.js";
|
|
10
13
|
import {
|
|
11
14
|
getCommonConfig
|
|
12
15
|
} from "./chunk-SFPMFVSD.js";
|
|
13
|
-
import {
|
|
14
|
-
getResolvedCacheConfig
|
|
15
|
-
} from "./chunk-TFD3DSM2.js";
|
|
16
16
|
|
|
17
17
|
// src/system/environment.ts
|
|
18
18
|
import os from "os";
|
|
@@ -38,19 +38,19 @@ function checkEnvironmentVariables() {
|
|
|
38
38
|
});
|
|
39
39
|
if (cache.redis) {
|
|
40
40
|
results.push({
|
|
41
|
-
key: "
|
|
41
|
+
key: "REDIS_REST_URL",
|
|
42
42
|
ok: true,
|
|
43
43
|
value: cache.redis.url.length > 20 ? cache.redis.url.substring(0, 20) + "..." : cache.redis.url
|
|
44
44
|
});
|
|
45
|
-
results.push({ key: "
|
|
45
|
+
results.push({ key: "REDIS_REST_TOKEN", ok: true, value: "***" });
|
|
46
46
|
} else {
|
|
47
|
-
results.push({ key: "
|
|
48
|
-
results.push({ key: "
|
|
47
|
+
results.push({ key: "REDIS_REST_URL", ok: false });
|
|
48
|
+
results.push({ key: "REDIS_REST_TOKEN", ok: false });
|
|
49
49
|
}
|
|
50
50
|
} catch (e) {
|
|
51
51
|
results.push({ key: "CACHE_ENABLED", ok: false });
|
|
52
|
-
results.push({ key: "
|
|
53
|
-
results.push({ key: "
|
|
52
|
+
results.push({ key: "REDIS_REST_URL", ok: false });
|
|
53
|
+
results.push({ key: "REDIS_REST_TOKEN", ok: false });
|
|
54
54
|
}
|
|
55
55
|
try {
|
|
56
56
|
const geo = getGeolocationConfig();
|
|
@@ -31,15 +31,7 @@ var CACHE_TTL_DEFAULTS = {
|
|
|
31
31
|
/** 분석 데이터 TTL (30분) */
|
|
32
32
|
ANALYTICS: THIRTY_MINUTES,
|
|
33
33
|
/** 사용자 데이터 TTL (30분) */
|
|
34
|
-
USER: THIRTY_MINUTES
|
|
35
|
-
/** 링크 데이터 TTL (30분) */
|
|
36
|
-
LINK: THIRTY_MINUTES,
|
|
37
|
-
/** 별칭 TTL (5분) - 자주 확인되는 데이터 */
|
|
38
|
-
ALIAS: FIVE_MINUTES,
|
|
39
|
-
/** 커뮤니티 TTL (15분) */
|
|
40
|
-
COMMUNITY: FIFTEEN_MINUTES,
|
|
41
|
-
/** 예약어 TTL (30분) */
|
|
42
|
-
RESERVED_WORDS: THIRTY_MINUTES
|
|
34
|
+
USER: THIRTY_MINUTES
|
|
43
35
|
};
|
|
44
36
|
var CACHE_DURATION_DEFAULTS = {
|
|
45
37
|
/** 분석 데이터 (30분) */
|
|
@@ -50,22 +42,8 @@ var CACHE_DURATION_DEFAULTS = {
|
|
|
50
42
|
GEOIP: THIRTY_DAYS,
|
|
51
43
|
/** 설정 데이터 (30분) */
|
|
52
44
|
SETTINGS: THIRTY_MINUTES,
|
|
53
|
-
/** 예약어 데이터 (30분) */
|
|
54
|
-
RESERVED_WORDS: THIRTY_MINUTES,
|
|
55
|
-
/** 별칭 데이터 (5분) */
|
|
56
|
-
ALIAS: FIVE_MINUTES,
|
|
57
|
-
/** 커뮤니티 데이터 (15분) */
|
|
58
|
-
COMMUNITY: FIFTEEN_MINUTES,
|
|
59
|
-
/** 링크 데이터 (30분) */
|
|
60
|
-
LINK: THIRTY_MINUTES,
|
|
61
45
|
/** Rate Limit (1분) */
|
|
62
|
-
RATE_LIMIT: ONE_MINUTE
|
|
63
|
-
/** URL 토큰 (5분) */
|
|
64
|
-
URL_TOKEN: FIVE_MINUTES,
|
|
65
|
-
/** API 키 (5분) */
|
|
66
|
-
API_KEY: FIVE_MINUTES,
|
|
67
|
-
/** API 설정 (10분) */
|
|
68
|
-
API_CONFIG: TEN_MINUTES
|
|
46
|
+
RATE_LIMIT: ONE_MINUTE
|
|
69
47
|
};
|
|
70
48
|
var CACHE_FALLBACK_DEFAULTS = {
|
|
71
49
|
/** 전역 Redis 에러 임계값 (이 값 이상이면 즉시 전역 비활성화) */
|
|
@@ -104,8 +82,8 @@ var CACHE_ENV_VARS = {
|
|
|
104
82
|
CACHE_INMEMORY_EVICTION: "CACHE_INMEMORY_EVICTION",
|
|
105
83
|
CACHE_INMEMORY_CLEANUP_INTERVAL: "CACHE_INMEMORY_CLEANUP_INTERVAL",
|
|
106
84
|
// Redis 설정
|
|
107
|
-
|
|
108
|
-
|
|
85
|
+
REDIS_REST_URL: "REDIS_REST_URL",
|
|
86
|
+
REDIS_REST_TOKEN: "REDIS_REST_TOKEN",
|
|
109
87
|
// TTL 설정
|
|
110
88
|
CACHE_TTL_DEFAULT: "CACHE_TTL_DEFAULT",
|
|
111
89
|
CACHE_TTL_SHORT: "CACHE_TTL_SHORT",
|
|
@@ -114,10 +92,6 @@ var CACHE_ENV_VARS = {
|
|
|
114
92
|
CACHE_TTL_SETTINGS: "CACHE_TTL_SETTINGS",
|
|
115
93
|
CACHE_TTL_ANALYTICS: "CACHE_TTL_ANALYTICS",
|
|
116
94
|
CACHE_TTL_USER: "CACHE_TTL_USER",
|
|
117
|
-
CACHE_TTL_LINK: "CACHE_TTL_LINK",
|
|
118
|
-
CACHE_TTL_ALIAS: "CACHE_TTL_ALIAS",
|
|
119
|
-
CACHE_TTL_COMMUNITY: "CACHE_TTL_COMMUNITY",
|
|
120
|
-
CACHE_TTL_RESERVED_WORDS: "CACHE_TTL_RESERVED_WORDS",
|
|
121
95
|
// 폴백 설정
|
|
122
96
|
CACHE_REDIS_ERROR_THRESHOLD_GLOBAL: "CACHE_REDIS_ERROR_THRESHOLD_GLOBAL",
|
|
123
97
|
CACHE_REDIS_ERROR_THRESHOLD_LOCAL: "CACHE_REDIS_ERROR_THRESHOLD_LOCAL",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getENV,
|
|
3
|
+
isCacheEnabled
|
|
4
|
+
} from "./chunk-BJLLMVWW.js";
|
|
5
|
+
|
|
6
|
+
// src/cache/cache-config.ts
|
|
7
|
+
var getCacheConfig = {
|
|
8
|
+
// Analytics 캐시 설정
|
|
9
|
+
analytics: {
|
|
10
|
+
enabled: () => getENV().CACHE.ANALYTICS.ENABLED && isCacheEnabled(),
|
|
11
|
+
duration: () => getENV().CACHE.ANALYTICS.DURATION
|
|
12
|
+
},
|
|
13
|
+
// User 캐시 설정
|
|
14
|
+
user: {
|
|
15
|
+
enabled: () => getENV().CACHE.USER.ENABLED && isCacheEnabled(),
|
|
16
|
+
duration: () => getENV().CACHE.USER.DURATION
|
|
17
|
+
},
|
|
18
|
+
// GeoIP 캐시 설정
|
|
19
|
+
geoip: {
|
|
20
|
+
enabled: () => getENV().CACHE.GEOIP.ENABLED && isCacheEnabled(),
|
|
21
|
+
duration: () => getENV().CACHE.GEOIP.DURATION
|
|
22
|
+
},
|
|
23
|
+
// Settings 캐시 설정
|
|
24
|
+
settings: {
|
|
25
|
+
enabled: () => getENV().CACHE.SETTINGS.ENABLED && isCacheEnabled(),
|
|
26
|
+
duration: () => getENV().CACHE.SETTINGS.DURATION
|
|
27
|
+
},
|
|
28
|
+
// Rate Limiter 캐시 설정
|
|
29
|
+
rateLimit: {
|
|
30
|
+
enabled: () => getENV().CACHE.RATE_LIMIT.ENABLED && isCacheEnabled(),
|
|
31
|
+
duration: () => getENV().CACHE.RATE_LIMIT.DURATION
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var getCacheTTL = {
|
|
35
|
+
settings: () => getCacheConfig.settings.duration(),
|
|
36
|
+
user: () => getCacheConfig.user.duration(),
|
|
37
|
+
analytics: () => getCacheConfig.analytics.duration(),
|
|
38
|
+
geoip: () => getCacheConfig.geoip.duration(),
|
|
39
|
+
default: () => getCacheConfig.analytics.duration()
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
getCacheConfig,
|
|
44
|
+
getCacheTTL
|
|
45
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getResolvedCacheConfig
|
|
3
|
+
} from "./chunk-UCIUAZQT.js";
|
|
1
4
|
import {
|
|
2
5
|
getCommonConfig
|
|
3
6
|
} from "./chunk-SFPMFVSD.js";
|
|
4
|
-
import {
|
|
5
|
-
getResolvedCacheConfig
|
|
6
|
-
} from "./chunk-TFD3DSM2.js";
|
|
7
7
|
|
|
8
8
|
// src/cache/cache-env.ts
|
|
9
9
|
function _getNodeEnv() {
|
|
@@ -14,14 +14,14 @@ function _getNodeEnv() {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
function getConfig() {
|
|
17
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
18
18
|
const cc = getResolvedCacheConfig();
|
|
19
19
|
const nodeEnv = _getNodeEnv();
|
|
20
20
|
return {
|
|
21
21
|
env: {
|
|
22
22
|
NODE_ENV: nodeEnv,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
REDIS_REST_URL: (_a = cc.redis) == null ? void 0 : _a.url,
|
|
24
|
+
REDIS_REST_TOKEN: (_b = cc.redis) == null ? void 0 : _b.token,
|
|
25
25
|
CACHE_ENABLED: cc.enabled
|
|
26
26
|
},
|
|
27
27
|
ENV: {
|
|
@@ -58,37 +58,9 @@ function getConfig() {
|
|
|
58
58
|
ENABLED: (_x = (_w = cc.categories.SETTINGS) == null ? void 0 : _w.enabled) != null ? _x : true,
|
|
59
59
|
DURATION: (_z = (_y = cc.categories.SETTINGS) == null ? void 0 : _y.duration) != null ? _z : 1800
|
|
60
60
|
},
|
|
61
|
-
RESERVED_WORDS: {
|
|
62
|
-
ENABLED: (_B = (_A = cc.categories.RESERVED_WORDS) == null ? void 0 : _A.enabled) != null ? _B : true,
|
|
63
|
-
DURATION: (_D = (_C = cc.categories.RESERVED_WORDS) == null ? void 0 : _C.duration) != null ? _D : 1800
|
|
64
|
-
},
|
|
65
|
-
ALIAS: {
|
|
66
|
-
ENABLED: (_F = (_E = cc.categories.ALIAS) == null ? void 0 : _E.enabled) != null ? _F : true,
|
|
67
|
-
DURATION: (_H = (_G = cc.categories.ALIAS) == null ? void 0 : _G.duration) != null ? _H : 300
|
|
68
|
-
},
|
|
69
|
-
COMMUNITY: {
|
|
70
|
-
ENABLED: (_J = (_I = cc.categories.COMMUNITY) == null ? void 0 : _I.enabled) != null ? _J : true,
|
|
71
|
-
DURATION: (_L = (_K = cc.categories.COMMUNITY) == null ? void 0 : _K.duration) != null ? _L : 900
|
|
72
|
-
},
|
|
73
|
-
LINK: {
|
|
74
|
-
ENABLED: (_N = (_M = cc.categories.LINK) == null ? void 0 : _M.enabled) != null ? _N : true,
|
|
75
|
-
DURATION: (_P = (_O = cc.categories.LINK) == null ? void 0 : _O.duration) != null ? _P : 1800
|
|
76
|
-
},
|
|
77
61
|
RATE_LIMIT: {
|
|
78
62
|
ENABLED: true,
|
|
79
|
-
DURATION: (
|
|
80
|
-
},
|
|
81
|
-
URL_TOKEN: {
|
|
82
|
-
ENABLED: (_T = (_S = cc.categories.URL_TOKEN) == null ? void 0 : _S.enabled) != null ? _T : true,
|
|
83
|
-
DURATION: (_V = (_U = cc.categories.URL_TOKEN) == null ? void 0 : _U.duration) != null ? _V : 300
|
|
84
|
-
},
|
|
85
|
-
API_KEY: {
|
|
86
|
-
ENABLED: (_X = (_W = cc.categories.API_KEY) == null ? void 0 : _W.enabled) != null ? _X : true,
|
|
87
|
-
DURATION: (_Z = (_Y = cc.categories.API_KEY) == null ? void 0 : _Y.duration) != null ? _Z : 300
|
|
88
|
-
},
|
|
89
|
-
API_CONFIG: {
|
|
90
|
-
ENABLED: (_$ = (__ = cc.categories.API_CONFIG) == null ? void 0 : __.enabled) != null ? _$ : true,
|
|
91
|
-
DURATION: (_ba = (_aa = cc.categories.API_CONFIG) == null ? void 0 : _aa.duration) != null ? _ba : 600
|
|
63
|
+
DURATION: (_B = (_A = cc.categories.RATE_LIMIT) == null ? void 0 : _A.duration) != null ? _B : 60
|
|
92
64
|
}
|
|
93
65
|
}
|
|
94
66
|
},
|
|
@@ -109,14 +81,14 @@ function validateRedisEnvironment() {
|
|
|
109
81
|
const redisUrl = (_a = cc.redis) == null ? void 0 : _a.url;
|
|
110
82
|
const redisToken = (_b = cc.redis) == null ? void 0 : _b.token;
|
|
111
83
|
if (!redisUrl) {
|
|
112
|
-
errors.push("
|
|
84
|
+
errors.push("Redis URL is not configured.");
|
|
113
85
|
} else if (redisUrl.trim() === "") {
|
|
114
|
-
errors.push("
|
|
86
|
+
errors.push("Redis URL is an empty string.");
|
|
115
87
|
}
|
|
116
88
|
if (!redisToken) {
|
|
117
|
-
errors.push("
|
|
89
|
+
errors.push("Redis token is not configured.");
|
|
118
90
|
} else if (redisToken.trim() === "") {
|
|
119
|
-
errors.push("
|
|
91
|
+
errors.push("Redis token is an empty string.");
|
|
120
92
|
}
|
|
121
93
|
return {
|
|
122
94
|
isValid: errors.length === 0,
|
|
@@ -27,12 +27,6 @@ var MAGIC_LINK = {
|
|
|
27
27
|
/** 토큰 길이 (바이트) */
|
|
28
28
|
TOKEN_LENGTH: 32
|
|
29
29
|
};
|
|
30
|
-
var API_KEY = {
|
|
31
|
-
/** 키 길이 (문자) */
|
|
32
|
-
LENGTH: 32,
|
|
33
|
-
/** 키 접두사 */
|
|
34
|
-
PREFIX: "tlog_"
|
|
35
|
-
};
|
|
36
30
|
var SESSION = {
|
|
37
31
|
/** 세션 쿠키 이름 */
|
|
38
32
|
COOKIE_NAME: "session",
|
|
@@ -67,7 +61,6 @@ export {
|
|
|
67
61
|
EMAIL_VERIFICATION,
|
|
68
62
|
PASSWORD_RESET,
|
|
69
63
|
MAGIC_LINK,
|
|
70
|
-
API_KEY,
|
|
71
64
|
SESSION,
|
|
72
65
|
OAUTH,
|
|
73
66
|
CSRF,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCacheConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7LJWRKDT.js";
|
|
4
4
|
import {
|
|
5
5
|
getENV
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BJLLMVWW.js";
|
|
7
7
|
|
|
8
8
|
// src/cache/noop-cache-manager.ts
|
|
9
9
|
var NoopCacheManager = class {
|
|
@@ -57,8 +57,8 @@ var NoopCacheManager = class {
|
|
|
57
57
|
envVars: {
|
|
58
58
|
CACHE_ENABLED: ENV.CACHE.ENABLED ? "true" : "false",
|
|
59
59
|
[envVarName]: "disabled",
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
REDIS_REST_URL: ENV.REDIS.URL ? "\uC124\uC815\uB428" : "\uBBF8\uC124\uC815",
|
|
61
|
+
REDIS_REST_TOKEN: ENV.REDIS.TOKEN ? "\uC124\uC815\uB428" : "\uBBF8\uC124\uC815"
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
InMemoryCacheManager
|
|
3
|
-
} from "./chunk-J4TTSXDN.js";
|
|
4
1
|
import {
|
|
5
2
|
isRedisGloballyDisabled,
|
|
6
3
|
notifyRedisError
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-X5RMDLLM.js";
|
|
5
|
+
import {
|
|
6
|
+
InMemoryCacheManager
|
|
7
|
+
} from "./chunk-J4TTSXDN.js";
|
|
8
8
|
import {
|
|
9
9
|
logger
|
|
10
10
|
} from "./chunk-GQVBWZLH.js";
|
|
11
11
|
import {
|
|
12
12
|
getCacheFallbackConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BJLLMVWW.js";
|
|
14
14
|
import {
|
|
15
15
|
__spreadValues
|
|
16
16
|
} from "./chunk-ORMEWXMH.js";
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NoopCacheManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CRWMULHR.js";
|
|
4
4
|
import {
|
|
5
5
|
RedisCacheManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NQQU6UFE.js";
|
|
7
7
|
import {
|
|
8
8
|
HybridCacheManager
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
InMemoryCacheManager
|
|
12
|
-
} from "./chunk-J4TTSXDN.js";
|
|
9
|
+
} from "./chunk-FUDEEQR3.js";
|
|
13
10
|
import {
|
|
14
11
|
isRedisAvailableNow,
|
|
15
12
|
isRedisGloballyDisabled
|
|
16
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-X5RMDLLM.js";
|
|
14
|
+
import {
|
|
15
|
+
InMemoryCacheManager
|
|
16
|
+
} from "./chunk-J4TTSXDN.js";
|
|
17
17
|
import {
|
|
18
18
|
logger
|
|
19
19
|
} from "./chunk-GQVBWZLH.js";
|
|
20
20
|
import {
|
|
21
21
|
getCacheConfig
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-7LJWRKDT.js";
|
|
23
23
|
import {
|
|
24
24
|
getENV,
|
|
25
25
|
isCacheEnabled
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-BJLLMVWW.js";
|
|
27
27
|
|
|
28
28
|
// src/cache/cache-factory.ts
|
|
29
29
|
function getInMemoryConfig() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatDatabaseError,
|
|
3
3
|
formatRedisError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YUBXS7YI.js";
|
|
5
5
|
import {
|
|
6
6
|
getPlatform
|
|
7
7
|
} from "./chunk-S5UCZ2T3.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-GQVBWZLH.js";
|
|
11
11
|
import {
|
|
12
12
|
getResolvedCacheConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-UCIUAZQT.js";
|
|
14
14
|
|
|
15
15
|
// src/system/health-check.ts
|
|
16
16
|
async function checkServiceHealth(prismaClient) {
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCommonConfig
|
|
3
|
+
} from "./chunk-SFPMFVSD.js";
|
|
1
4
|
import {
|
|
2
5
|
__spreadValues
|
|
3
6
|
} from "./chunk-ORMEWXMH.js";
|
|
4
7
|
|
|
5
8
|
// src/auth/core/jwt/cookie.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
function getDefaultOptions() {
|
|
10
|
+
let isProduction = false;
|
|
11
|
+
try {
|
|
12
|
+
isProduction = getCommonConfig().nodeEnv === "production";
|
|
13
|
+
} catch (e) {
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
secure: isProduction,
|
|
17
|
+
sameSite: "lax"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
10
20
|
function setTokenCookies(response, tokenPair, options = {}) {
|
|
11
|
-
const opts = __spreadValues(__spreadValues({},
|
|
21
|
+
const opts = __spreadValues(__spreadValues({}, getDefaultOptions()), options);
|
|
12
22
|
response.cookies.set("access_token", tokenPair.accessToken, {
|
|
13
23
|
httpOnly: true,
|
|
14
24
|
secure: opts.secure,
|
|
@@ -26,7 +36,7 @@ function setTokenCookies(response, tokenPair, options = {}) {
|
|
|
26
36
|
return response;
|
|
27
37
|
}
|
|
28
38
|
function clearTokenCookies(response, options = {}) {
|
|
29
|
-
const opts = __spreadValues(__spreadValues({},
|
|
39
|
+
const opts = __spreadValues(__spreadValues({}, getDefaultOptions()), options);
|
|
30
40
|
response.cookies.set("access_token", "", {
|
|
31
41
|
httpOnly: true,
|
|
32
42
|
secure: opts.secure,
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
isRedisGloballyDisabled,
|
|
4
4
|
notifyRedisError,
|
|
5
5
|
resetRedisGlobalState
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-X5RMDLLM.js";
|
|
7
7
|
import {
|
|
8
8
|
logger
|
|
9
9
|
} from "./chunk-GQVBWZLH.js";
|
|
10
10
|
import {
|
|
11
11
|
getENV,
|
|
12
12
|
isCacheEnabled
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BJLLMVWW.js";
|
|
14
14
|
import {
|
|
15
15
|
__spreadValues
|
|
16
16
|
} from "./chunk-ORMEWXMH.js";
|
|
@@ -105,8 +105,8 @@ var RedisCacheManager = class _RedisCacheManager {
|
|
|
105
105
|
redisAvailable: !!getRedisClient(),
|
|
106
106
|
envVars: {
|
|
107
107
|
CACHE_ENABLED: ENV.CACHE.ENABLED ? "true" : "false",
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
REDIS_REST_URL: ENV.REDIS.URL ? "\uC124\uC815\uB428" : "\uBBF8\uC124\uC815",
|
|
109
|
+
REDIS_REST_TOKEN: ENV.REDIS.TOKEN ? "\uC124\uC815\uB428" : "\uBBF8\uC124\uC815"
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
CACHE_HEALTH_DEFAULTS,
|
|
8
8
|
CACHE_TTL_DEFAULTS,
|
|
9
9
|
INMEMORY_CACHE_DEFAULTS
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-57W32BFZ.js";
|
|
11
11
|
import {
|
|
12
12
|
__spreadValues
|
|
13
13
|
} from "./chunk-ORMEWXMH.js";
|
|
@@ -22,7 +22,7 @@ function setConfig(config) {
|
|
|
22
22
|
globalThis[GLOBAL_KEY] = config;
|
|
23
23
|
}
|
|
24
24
|
function initializeCache(input) {
|
|
25
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z;
|
|
26
26
|
if (getConfig()) return;
|
|
27
27
|
if (input.redis !== void 0) {
|
|
28
28
|
if (!input.redis.url) {
|
|
@@ -68,27 +68,23 @@ function initializeCache(input) {
|
|
|
68
68
|
GEOIP: (_x = (_w = input.ttl) == null ? void 0 : _w.GEOIP) != null ? _x : CACHE_TTL_DEFAULTS.GEOIP,
|
|
69
69
|
SETTINGS: (_z = (_y = input.ttl) == null ? void 0 : _y.SETTINGS) != null ? _z : CACHE_TTL_DEFAULTS.SETTINGS,
|
|
70
70
|
ANALYTICS: (_B = (_A = input.ttl) == null ? void 0 : _A.ANALYTICS) != null ? _B : CACHE_TTL_DEFAULTS.ANALYTICS,
|
|
71
|
-
USER: (_D = (_C = input.ttl) == null ? void 0 : _C.USER) != null ? _D : CACHE_TTL_DEFAULTS.USER
|
|
72
|
-
LINK: (_F = (_E = input.ttl) == null ? void 0 : _E.LINK) != null ? _F : CACHE_TTL_DEFAULTS.LINK,
|
|
73
|
-
ALIAS: (_H = (_G = input.ttl) == null ? void 0 : _G.ALIAS) != null ? _H : CACHE_TTL_DEFAULTS.ALIAS,
|
|
74
|
-
COMMUNITY: (_J = (_I = input.ttl) == null ? void 0 : _I.COMMUNITY) != null ? _J : CACHE_TTL_DEFAULTS.COMMUNITY,
|
|
75
|
-
RESERVED_WORDS: (_L = (_K = input.ttl) == null ? void 0 : _K.RESERVED_WORDS) != null ? _L : CACHE_TTL_DEFAULTS.RESERVED_WORDS
|
|
71
|
+
USER: (_D = (_C = input.ttl) == null ? void 0 : _C.USER) != null ? _D : CACHE_TTL_DEFAULTS.USER
|
|
76
72
|
},
|
|
77
73
|
categories: mergedCategories,
|
|
78
74
|
fallback: {
|
|
79
|
-
redisErrorThresholdGlobal: (
|
|
80
|
-
redisErrorThresholdLocal: (
|
|
81
|
-
redisReconnectInterval: (
|
|
82
|
-
fallbackOnRedisError: (
|
|
83
|
-
writeToMemory: (
|
|
75
|
+
redisErrorThresholdGlobal: (_F = (_E = input.fallback) == null ? void 0 : _E.redisErrorThresholdGlobal) != null ? _F : CACHE_FALLBACK_DEFAULTS.REDIS_ERROR_THRESHOLD_GLOBAL,
|
|
76
|
+
redisErrorThresholdLocal: (_H = (_G = input.fallback) == null ? void 0 : _G.redisErrorThresholdLocal) != null ? _H : CACHE_FALLBACK_DEFAULTS.REDIS_ERROR_THRESHOLD_LOCAL,
|
|
77
|
+
redisReconnectInterval: (_J = (_I = input.fallback) == null ? void 0 : _I.redisReconnectInterval) != null ? _J : CACHE_FALLBACK_DEFAULTS.REDIS_RECONNECT_INTERVAL,
|
|
78
|
+
fallbackOnRedisError: (_L = (_K = input.fallback) == null ? void 0 : _K.fallbackOnRedisError) != null ? _L : CACHE_FALLBACK_DEFAULTS.FALLBACK_ON_REDIS_ERROR,
|
|
79
|
+
writeToMemory: (_N = (_M = input.fallback) == null ? void 0 : _M.writeToMemory) != null ? _N : CACHE_FALLBACK_DEFAULTS.WRITE_TO_MEMORY
|
|
84
80
|
},
|
|
85
81
|
health: {
|
|
86
|
-
errorRateThreshold: (
|
|
87
|
-
hitRateThreshold: (
|
|
88
|
-
reportHitRateThreshold: (
|
|
89
|
-
reportResponseTimeThreshold: (
|
|
90
|
-
reportInvalidationThreshold: (
|
|
91
|
-
reportMinRequests: (
|
|
82
|
+
errorRateThreshold: (_P = (_O = input.health) == null ? void 0 : _O.errorRateThreshold) != null ? _P : CACHE_HEALTH_DEFAULTS.ERROR_RATE_THRESHOLD,
|
|
83
|
+
hitRateThreshold: (_R = (_Q = input.health) == null ? void 0 : _Q.hitRateThreshold) != null ? _R : CACHE_HEALTH_DEFAULTS.HIT_RATE_THRESHOLD,
|
|
84
|
+
reportHitRateThreshold: (_T = (_S = input.health) == null ? void 0 : _S.reportHitRateThreshold) != null ? _T : CACHE_HEALTH_DEFAULTS.REPORT_HIT_RATE_THRESHOLD,
|
|
85
|
+
reportResponseTimeThreshold: (_V = (_U = input.health) == null ? void 0 : _U.reportResponseTimeThreshold) != null ? _V : CACHE_HEALTH_DEFAULTS.REPORT_RESPONSE_TIME_THRESHOLD,
|
|
86
|
+
reportInvalidationThreshold: (_X = (_W = input.health) == null ? void 0 : _W.reportInvalidationThreshold) != null ? _X : CACHE_HEALTH_DEFAULTS.REPORT_INVALIDATION_THRESHOLD,
|
|
87
|
+
reportMinRequests: (_Z = (_Y = input.health) == null ? void 0 : _Y.reportMinRequests) != null ? _Z : CACHE_HEALTH_DEFAULTS.REPORT_MIN_REQUESTS
|
|
92
88
|
}
|
|
93
89
|
});
|
|
94
90
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getEnv,
|
|
8
8
|
isCacheEnabled,
|
|
9
9
|
validateRedisEnvironment
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-BJLLMVWW.js";
|
|
11
11
|
|
|
12
12
|
// src/cache/cache-redis.ts
|
|
13
13
|
import { Redis } from "@upstash/redis";
|
|
@@ -72,13 +72,13 @@ async function tryReconnectRedisGlobally() {
|
|
|
72
72
|
logger.info("[Redis:Global] Attempting Redis reconnection...");
|
|
73
73
|
try {
|
|
74
74
|
const env = getEnv();
|
|
75
|
-
if (!env.
|
|
75
|
+
if (!env.REDIS_REST_URL || !env.REDIS_REST_TOKEN) {
|
|
76
76
|
scheduleNextReconnect();
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const redis = new Redis({
|
|
80
|
-
url: env.
|
|
81
|
-
token: env.
|
|
80
|
+
url: env.REDIS_REST_URL,
|
|
81
|
+
token: env.REDIS_REST_TOKEN
|
|
82
82
|
});
|
|
83
83
|
const pingResult = await redis.ping();
|
|
84
84
|
if (pingResult === "PONG") {
|
|
@@ -176,8 +176,8 @@ async function checkRedisConnection() {
|
|
|
176
176
|
logger.info("[Redis:Cache] Redis connection status check started", {
|
|
177
177
|
purpose: "cache"
|
|
178
178
|
});
|
|
179
|
-
const redisUrl = env.
|
|
180
|
-
const redisToken = env.
|
|
179
|
+
const redisUrl = env.REDIS_REST_URL;
|
|
180
|
+
const redisToken = env.REDIS_REST_TOKEN;
|
|
181
181
|
if (!redisUrl || !redisToken || redisUrl.trim() === "" || redisToken.trim() === "") {
|
|
182
182
|
const error = "Redis environment variables are not configured.";
|
|
183
183
|
logger.error("[Redis:Cache] Redis connection failed: Environment variables not set", {
|
|
@@ -271,13 +271,13 @@ function getRedisClient() {
|
|
|
271
271
|
return null;
|
|
272
272
|
}
|
|
273
273
|
const env = getEnv();
|
|
274
|
-
if (!env.
|
|
274
|
+
if (!env.REDIS_REST_URL || !env.REDIS_REST_TOKEN) {
|
|
275
275
|
_redisClient = null;
|
|
276
276
|
return null;
|
|
277
277
|
}
|
|
278
278
|
_redisClient = new Redis({
|
|
279
|
-
url: env.
|
|
280
|
-
token: env.
|
|
279
|
+
url: env.REDIS_REST_URL,
|
|
280
|
+
token: env.REDIS_REST_TOKEN
|
|
281
281
|
});
|
|
282
282
|
return _redisClient;
|
|
283
283
|
}
|
|
@@ -289,24 +289,24 @@ function logRedisInitialization() {
|
|
|
289
289
|
const redis = getRedisClient();
|
|
290
290
|
const env = getEnv();
|
|
291
291
|
if (isRedisAvailableNow() && redis) {
|
|
292
|
-
logger.info("[Redis:Cache]
|
|
292
|
+
logger.info("[Redis:Cache] Redis cache connection initialization complete", {
|
|
293
293
|
purpose: "cache",
|
|
294
|
-
url: ((_a = env.
|
|
294
|
+
url: ((_a = env.REDIS_REST_URL) == null ? void 0 : _a.substring(0, 50)) + "...",
|
|
295
295
|
cacheEnabled: isCacheEnabled()
|
|
296
296
|
});
|
|
297
297
|
} else if (!isCacheEnabled()) {
|
|
298
298
|
logger.info("[Redis:Cache] Redis cache disabled (CACHE_ENABLED=false)", {
|
|
299
299
|
purpose: "cache",
|
|
300
300
|
cacheEnabled: false,
|
|
301
|
-
redisUrlSet: !!env.
|
|
302
|
-
redisTokenSet: !!env.
|
|
301
|
+
redisUrlSet: !!env.REDIS_REST_URL,
|
|
302
|
+
redisTokenSet: !!env.REDIS_REST_TOKEN
|
|
303
303
|
});
|
|
304
304
|
} else {
|
|
305
305
|
logger.warn("[Redis:Cache] Cache disabled due to missing Redis environment variables", {
|
|
306
306
|
purpose: "cache",
|
|
307
307
|
cacheEnabled: isCacheEnabled(),
|
|
308
|
-
redisUrlSet: !!env.
|
|
309
|
-
redisTokenSet: !!env.
|
|
308
|
+
redisUrlSet: !!env.REDIS_REST_URL,
|
|
309
|
+
redisTokenSet: !!env.REDIS_REST_TOKEN
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
312
|
if (typeof globalThis !== "undefined") {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCacheManager,
|
|
3
3
|
getEffectiveCacheBackend
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GGSFZP6T.js";
|
|
5
5
|
import {
|
|
6
6
|
logger
|
|
7
7
|
} from "./chunk-GQVBWZLH.js";
|
|
8
8
|
import {
|
|
9
9
|
getCacheConfig,
|
|
10
10
|
getCacheTTL
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7LJWRKDT.js";
|
|
12
12
|
import {
|
|
13
13
|
isCacheEnabled
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BJLLMVWW.js";
|
|
15
15
|
|
|
16
16
|
// src/cache/cache-wrapper.ts
|
|
17
17
|
function getCacheBackendLabel() {
|