@withwiz/toolkit 0.2.8 → 0.3.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.
Files changed (124) hide show
  1. package/dist/auth/config.d.ts +13 -0
  2. package/dist/auth/config.js +13 -0
  3. package/dist/auth/index.js +18 -18
  4. package/dist/cache/cache-config.js +6 -3
  5. package/dist/cache/cache-env.d.ts +11 -20
  6. package/dist/cache/cache-env.js +5 -6
  7. package/dist/cache/cache-factory.js +14 -9
  8. package/dist/cache/cache-invalidation.js +15 -10
  9. package/dist/cache/cache-redis.js +8 -3
  10. package/dist/cache/cache-wrapper.js +15 -10
  11. package/dist/cache/cache.js +25 -17
  12. package/dist/cache/config.d.ts +113 -0
  13. package/dist/cache/config.js +13 -0
  14. package/dist/cache/hybrid-cache-manager.js +10 -5
  15. package/dist/cache/index.d.ts +2 -1
  16. package/dist/cache/index.js +25 -17
  17. package/dist/cache/inmemory-cache-manager.js +6 -2
  18. package/dist/cache/noop-cache-manager.js +7 -4
  19. package/dist/cache/redis-cache-manager.js +9 -4
  20. package/dist/chunk-2LCLLZME.js +122 -0
  21. package/dist/chunk-2QH66EVQ.js +11 -0
  22. package/dist/{chunk-YVF4RXOK.js → chunk-3GKJ763I.js} +12 -12
  23. package/dist/{chunk-XN4YP4XO.js → chunk-4CSSGCW5.js} +5 -5
  24. package/dist/{chunk-WZDS4QEC.js → chunk-576PAKLR.js} +1 -1
  25. package/dist/chunk-5MBKG2ZD.js +32 -0
  26. package/dist/{chunk-74MSBKYW.js → chunk-5P4E6SGV.js} +17 -13
  27. package/dist/{chunk-R5OFGX3C.js → chunk-6VNEAK73.js} +6 -6
  28. package/dist/{chunk-QF6FH4GZ.js → chunk-AWFY2HWG.js} +5 -5
  29. package/dist/{chunk-YMIDD4YE.js → chunk-BJWG3LH5.js} +6 -6
  30. package/dist/{chunk-BX5CNRVS.js → chunk-BY653UR3.js} +2 -2
  31. package/dist/{chunk-HCTNZM7D.js → chunk-C3WPAWID.js} +1 -1
  32. package/dist/{chunk-JOGXLVUZ.js → chunk-CZHFHEBG.js} +5 -5
  33. package/dist/{chunk-WSUFD4SO.js → chunk-DC2OFQ43.js} +17 -9
  34. package/dist/{chunk-HOMWLK62.js → chunk-FGA7VLYK.js} +2 -2
  35. package/dist/{chunk-T3YUJYBX.js → chunk-FIRLRKET.js} +1 -1
  36. package/dist/{chunk-LEWQBXN6.js → chunk-FO77EZCU.js} +1 -1
  37. package/dist/{chunk-WEDR5GJO.js → chunk-GRGOD3W5.js} +2 -2
  38. package/dist/{chunk-JWZSWMOM.js → chunk-HKJCBV3H.js} +6 -6
  39. package/dist/chunk-ITSXXSFN.js +42 -0
  40. package/dist/{chunk-6WVKLXVT.js → chunk-JGGGHEBC.js} +1 -1
  41. package/dist/chunk-JNB7MWG4.js +40 -0
  42. package/dist/chunk-JTPLPUI7.js +102 -0
  43. package/dist/chunk-K25ICPU4.js +8 -0
  44. package/dist/{chunk-IT43YQND.js → chunk-KAIGEZAL.js} +20 -5
  45. package/dist/{chunk-AOZVTVJG.js → chunk-L6M4DZV2.js} +1 -1
  46. package/dist/{chunk-RPWEGUUS.js → chunk-LX2EYD74.js} +8 -8
  47. package/dist/{chunk-QMZ75GBU.js → chunk-M776IH4D.js} +3 -3
  48. package/dist/{chunk-DH2ZHGW2.js → chunk-MVH5ZPFD.js} +14 -2
  49. package/dist/{chunk-WDJLAZCW.js → chunk-NE33JZW3.js} +18 -3
  50. package/dist/{chunk-3GEQQ4VL.js → chunk-NWAN2VRP.js} +12 -12
  51. package/dist/{chunk-I5PCM2JQ.js → chunk-PU2LFTI5.js} +4 -4
  52. package/dist/{chunk-4NWJ3WCZ.js → chunk-Q7NIAITA.js} +8 -1
  53. package/dist/chunk-RLXRDUBX.js +38 -0
  54. package/dist/{chunk-5A2L6TXD.js → chunk-SNNXLA5F.js} +34 -15
  55. package/dist/{chunk-M5LIX3TD.js → chunk-STNIT65W.js} +1 -1
  56. package/dist/{chunk-NJXCFTOE.js → chunk-UD7YHLHI.js} +1 -1
  57. package/dist/{chunk-GCZOXUDV.js → chunk-USL5SQLZ.js} +50 -10
  58. package/dist/chunk-V33BEN6H.js +31 -0
  59. package/dist/chunk-X2QSMX3B.js +156 -0
  60. package/dist/{chunk-Y6IHEA3Q.js → chunk-XZ4HMXSK.js} +1 -1
  61. package/dist/chunk-YCIYDWJU.js +37 -0
  62. package/dist/{chunk-7KCWVRPR.js → chunk-ZBU2DYLD.js} +2 -2
  63. package/dist/{chunk-67KRDPIH.js → chunk-ZFFWKCHN.js} +2 -2
  64. package/dist/components/ui/DataTable.js +5 -5
  65. package/dist/components/ui/data-table/DataTable.js +5 -5
  66. package/dist/components/ui/data-table/DataTableFilters.js +2 -2
  67. package/dist/components/ui/data-table/DataTableSearch.js +2 -2
  68. package/dist/config/common.d.ts +9 -0
  69. package/dist/config/common.js +13 -0
  70. package/dist/config/errors.d.ts +3 -0
  71. package/dist/config/errors.js +7 -0
  72. package/dist/config/warn.d.ts +4 -0
  73. package/dist/config/warn.js +7 -0
  74. package/dist/constants/index.js +23 -23
  75. package/dist/error/error-display.js +2 -2
  76. package/dist/error/error-handler.js +7 -3
  77. package/dist/error/index.js +17 -13
  78. package/dist/geolocation/batch-processor.js +6 -2
  79. package/dist/geolocation/config.d.ts +11 -0
  80. package/dist/geolocation/config.js +13 -0
  81. package/dist/geolocation/index.js +13 -8
  82. package/dist/geolocation/providers/index.js +9 -6
  83. package/dist/geolocation/providers/ipgeolocation-provider.js +4 -1
  84. package/dist/geolocation/providers/maxmind-provider.js +4 -1
  85. package/dist/initialize.d.ts +18 -0
  86. package/dist/initialize.js +41 -0
  87. package/dist/logger/config.d.ts +17 -0
  88. package/dist/logger/config.js +13 -0
  89. package/dist/logger/logger.js +5 -1
  90. package/dist/middleware/auth.js +8 -3
  91. package/dist/middleware/cors-config.d.ts +11 -0
  92. package/dist/middleware/cors-config.js +13 -0
  93. package/dist/middleware/cors.js +7 -2
  94. package/dist/middleware/error-handler.js +9 -5
  95. package/dist/middleware/index.js +23 -17
  96. package/dist/middleware/middleware-chain.js +6 -2
  97. package/dist/middleware/rate-limit.js +6 -2
  98. package/dist/middleware/response-logger.js +6 -2
  99. package/dist/middleware/security.js +6 -2
  100. package/dist/middleware/wrappers.js +18 -12
  101. package/dist/storage/config.d.ts +17 -0
  102. package/dist/storage/config.js +13 -0
  103. package/dist/storage/r2-storage.d.ts +4 -0
  104. package/dist/storage/r2-storage.js +19 -10
  105. package/dist/system/cpu.js +7 -3
  106. package/dist/system/disk.js +7 -3
  107. package/dist/system/environment.js +11 -3
  108. package/dist/system/health-check.js +9 -3
  109. package/dist/system/index.js +18 -10
  110. package/dist/system/memory.js +7 -3
  111. package/dist/system/network.js +7 -3
  112. package/dist/system/utils.js +6 -2
  113. package/dist/types/env.d.ts +12 -2
  114. package/dist/utils/cors.js +5 -1
  115. package/dist/utils/csv-export.js +6 -2
  116. package/dist/utils/error-processor.js +6 -2
  117. package/dist/utils/index.js +31 -26
  118. package/package.json +10 -1
  119. package/dist/chunk-N4XYQB2G.js +0 -193
  120. package/dist/chunk-OFPRBEO6.js +0 -93
  121. package/dist/{chunk-TH45RVP7.js → chunk-KHYY4KCV.js} +3 -3
  122. package/dist/{chunk-EBUEBEJX.js → chunk-QMCOX3DP.js} +0 -0
  123. package/dist/{chunk-X2UP5PNN.js → chunk-SEZJN4TC.js} +3 -3
  124. package/dist/{chunk-IJCVFLEY.js → chunk-TQJDNWBL.js} +3 -3
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  NoopCacheManager
3
- } from "../chunk-HOMWLK62.js";
4
- import "../chunk-HCTNZM7D.js";
5
- import "../chunk-N4XYQB2G.js";
6
- import "../chunk-5A2L6TXD.js";
3
+ } from "../chunk-FGA7VLYK.js";
4
+ import "../chunk-C3WPAWID.js";
5
+ import "../chunk-X2QSMX3B.js";
6
+ import "../chunk-JTPLPUI7.js";
7
+ import "../chunk-5MBKG2ZD.js";
7
8
  import "../chunk-IQQKKUAV.js";
9
+ import "../chunk-K25ICPU4.js";
10
+ import "../chunk-2QH66EVQ.js";
8
11
  import "../chunk-ORMEWXMH.js";
9
12
  export {
10
13
  NoopCacheManager
@@ -1,10 +1,15 @@
1
1
  import {
2
2
  RedisCacheManager
3
- } from "../chunk-XN4YP4XO.js";
4
- import "../chunk-I5PCM2JQ.js";
5
- import "../chunk-N4XYQB2G.js";
6
- import "../chunk-5A2L6TXD.js";
3
+ } from "../chunk-4CSSGCW5.js";
4
+ import "../chunk-PU2LFTI5.js";
5
+ import "../chunk-SNNXLA5F.js";
6
+ import "../chunk-X2QSMX3B.js";
7
+ import "../chunk-RLXRDUBX.js";
8
+ import "../chunk-JTPLPUI7.js";
9
+ import "../chunk-5MBKG2ZD.js";
7
10
  import "../chunk-IQQKKUAV.js";
11
+ import "../chunk-K25ICPU4.js";
12
+ import "../chunk-2QH66EVQ.js";
8
13
  import "../chunk-ORMEWXMH.js";
9
14
  export {
10
15
  RedisCacheManager
@@ -0,0 +1,122 @@
1
+ import {
2
+ getPlatform
3
+ } from "./chunk-JGGGHEBC.js";
4
+ import {
5
+ getGeolocationConfig
6
+ } from "./chunk-V33BEN6H.js";
7
+ import {
8
+ getResolvedCacheConfig
9
+ } from "./chunk-JTPLPUI7.js";
10
+ import {
11
+ getCommonConfig
12
+ } from "./chunk-5MBKG2ZD.js";
13
+ import {
14
+ getAuthConfig
15
+ } from "./chunk-ITSXXSFN.js";
16
+
17
+ // src/system/environment.ts
18
+ import os from "os";
19
+ function checkEnvironmentVariables() {
20
+ const platform = getPlatform();
21
+ const results = [];
22
+ try {
23
+ const auth = getAuthConfig();
24
+ results.push({
25
+ key: "JWT_SECRET",
26
+ ok: true,
27
+ value: auth.jwtSecret.length > 20 ? auth.jwtSecret.substring(0, 20) + "..." : auth.jwtSecret
28
+ });
29
+ } catch (e) {
30
+ results.push({ key: "JWT_SECRET", ok: false });
31
+ }
32
+ try {
33
+ const cache = getResolvedCacheConfig();
34
+ results.push({
35
+ key: "CACHE_ENABLED",
36
+ ok: true,
37
+ value: String(cache.enabled)
38
+ });
39
+ if (cache.redis) {
40
+ results.push({
41
+ key: "UPSTASH_REDIS_REST_URL",
42
+ ok: true,
43
+ value: cache.redis.url.length > 20 ? cache.redis.url.substring(0, 20) + "..." : cache.redis.url
44
+ });
45
+ results.push({ key: "UPSTASH_REDIS_REST_TOKEN", ok: true, value: "***" });
46
+ } else {
47
+ results.push({ key: "UPSTASH_REDIS_REST_URL", ok: false });
48
+ results.push({ key: "UPSTASH_REDIS_REST_TOKEN", ok: false });
49
+ }
50
+ } catch (e) {
51
+ results.push({ key: "CACHE_ENABLED", ok: false });
52
+ results.push({ key: "UPSTASH_REDIS_REST_URL", ok: false });
53
+ results.push({ key: "UPSTASH_REDIS_REST_TOKEN", ok: false });
54
+ }
55
+ try {
56
+ const geo = getGeolocationConfig();
57
+ results.push({ key: "IPGEOLOCATION_API_KEY", ok: !!geo.ipgeolocationApiKey });
58
+ results.push({ key: "MAXMIND_LICENSE_KEY", ok: !!geo.maxmindLicenseKey });
59
+ } catch (e) {
60
+ results.push({ key: "IPGEOLOCATION_API_KEY", ok: false });
61
+ results.push({ key: "MAXMIND_LICENSE_KEY", ok: false });
62
+ }
63
+ results.push({
64
+ key: "PLATFORM",
65
+ ok: true,
66
+ value: platform === "darwin" ? "macOS" : "Linux"
67
+ });
68
+ let nodeEnvValue;
69
+ try {
70
+ nodeEnvValue = getCommonConfig().nodeEnv;
71
+ } catch (e) {
72
+ nodeEnvValue = "development";
73
+ }
74
+ results.push({
75
+ key: "NODE_ENV",
76
+ ok: true,
77
+ value: nodeEnvValue
78
+ });
79
+ results.push({
80
+ key: "ARCHITECTURE",
81
+ ok: true,
82
+ value: process.arch
83
+ });
84
+ results.push({
85
+ key: "NODE_VERSION",
86
+ ok: true,
87
+ value: process.version
88
+ });
89
+ results.push({
90
+ key: "HOSTNAME",
91
+ ok: true,
92
+ value: os.hostname()
93
+ });
94
+ results.push({
95
+ key: "USER_HOME",
96
+ ok: true,
97
+ value: os.homedir()
98
+ });
99
+ results.push({
100
+ key: "TEMP_DIR",
101
+ ok: true,
102
+ value: os.tmpdir()
103
+ });
104
+ if (platform === "darwin") {
105
+ results.push({
106
+ key: "MACOS_VERSION",
107
+ ok: true,
108
+ value: os.release()
109
+ });
110
+ } else {
111
+ results.push({
112
+ key: "LINUX_DISTRO",
113
+ ok: true,
114
+ value: os.release()
115
+ });
116
+ }
117
+ return results;
118
+ }
119
+
120
+ export {
121
+ checkEnvironmentVariables
122
+ };
@@ -0,0 +1,11 @@
1
+ // src/config/errors.ts
2
+ var ConfigurationError = class extends Error {
3
+ constructor(module, message) {
4
+ super(`[${module}] ${message}`);
5
+ this.name = "ConfigurationError";
6
+ }
7
+ };
8
+
9
+ export {
10
+ ConfigurationError
11
+ };
@@ -1,29 +1,29 @@
1
+ import {
2
+ RedisCacheManager
3
+ } from "./chunk-4CSSGCW5.js";
1
4
  import {
2
5
  HybridCacheManager
3
- } from "./chunk-R5OFGX3C.js";
6
+ } from "./chunk-6VNEAK73.js";
4
7
  import {
5
8
  InMemoryCacheManager
6
- } from "./chunk-Y6IHEA3Q.js";
9
+ } from "./chunk-XZ4HMXSK.js";
7
10
  import {
8
11
  NoopCacheManager
9
- } from "./chunk-HOMWLK62.js";
10
- import {
11
- RedisCacheManager
12
- } from "./chunk-XN4YP4XO.js";
12
+ } from "./chunk-FGA7VLYK.js";
13
13
  import {
14
14
  getCacheConfig
15
- } from "./chunk-HCTNZM7D.js";
15
+ } from "./chunk-C3WPAWID.js";
16
16
  import {
17
17
  isRedisAvailableNow,
18
18
  isRedisGloballyDisabled
19
- } from "./chunk-I5PCM2JQ.js";
19
+ } from "./chunk-PU2LFTI5.js";
20
+ import {
21
+ logger
22
+ } from "./chunk-SNNXLA5F.js";
20
23
  import {
21
24
  getENV,
22
25
  isCacheEnabled
23
- } from "./chunk-N4XYQB2G.js";
24
- import {
25
- logger
26
- } from "./chunk-5A2L6TXD.js";
26
+ } from "./chunk-X2QSMX3B.js";
27
27
 
28
28
  // src/cache/cache-factory.ts
29
29
  function getInMemoryConfig() {
@@ -3,14 +3,14 @@ import {
3
3
  isRedisGloballyDisabled,
4
4
  notifyRedisError,
5
5
  resetRedisGlobalState
6
- } from "./chunk-I5PCM2JQ.js";
6
+ } from "./chunk-PU2LFTI5.js";
7
+ import {
8
+ logger
9
+ } from "./chunk-SNNXLA5F.js";
7
10
  import {
8
11
  getENV,
9
12
  isCacheEnabled
10
- } from "./chunk-N4XYQB2G.js";
11
- import {
12
- logger
13
- } from "./chunk-5A2L6TXD.js";
13
+ } from "./chunk-X2QSMX3B.js";
14
14
  import {
15
15
  __spreadValues
16
16
  } from "./chunk-ORMEWXMH.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-5A2L6TXD.js";
3
+ } from "./chunk-SNNXLA5F.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -0,0 +1,32 @@
1
+ import {
2
+ configWarn
3
+ } from "./chunk-K25ICPU4.js";
4
+ import {
5
+ ConfigurationError
6
+ } from "./chunk-2QH66EVQ.js";
7
+
8
+ // src/config/common.ts
9
+ var _config = null;
10
+ function initializeCommon(config) {
11
+ var _a;
12
+ if (_config) return;
13
+ if (!config.nodeEnv) {
14
+ configWarn("Common", "nodeEnv not provided, using default: development");
15
+ }
16
+ _config = { nodeEnv: (_a = config.nodeEnv) != null ? _a : "development" };
17
+ }
18
+ function getCommonConfig() {
19
+ if (!_config) {
20
+ throw new ConfigurationError("Common", "Not initialized. Call initializeCommon() first.");
21
+ }
22
+ return _config;
23
+ }
24
+ function resetCommon() {
25
+ _config = null;
26
+ }
27
+
28
+ export {
29
+ initializeCommon,
30
+ getCommonConfig,
31
+ resetCommon
32
+ };
@@ -2,14 +2,17 @@ import {
2
2
  AppError
3
3
  } from "./chunk-KXXROUA5.js";
4
4
  import {
5
- ERROR_CODES
6
- } from "./chunk-SNVGJPPX.js";
5
+ logger
6
+ } from "./chunk-SNNXLA5F.js";
7
+ import {
8
+ getAuthConfig
9
+ } from "./chunk-ITSXXSFN.js";
7
10
  import {
8
11
  JWTManager
9
12
  } from "./chunk-2ATBAIRL.js";
10
13
  import {
11
- logger
12
- } from "./chunk-5A2L6TXD.js";
14
+ ERROR_CODES
15
+ } from "./chunk-SNVGJPPX.js";
13
16
 
14
17
  // src/middleware/auth.ts
15
18
  function setAccessTokenBlacklistChecker(checker) {
@@ -26,17 +29,19 @@ var _jwtManager = null;
26
29
  var _jwtWarningLogged = false;
27
30
  function getJWTManager() {
28
31
  if (!_jwtManager) {
29
- const secret = process.env.JWT_SECRET;
30
- if (!secret) {
32
+ let authConfig;
33
+ try {
34
+ authConfig = getAuthConfig();
35
+ } catch (e) {
31
36
  if (!_jwtWarningLogged) {
32
37
  logger.warn(
33
- "[Auth Middleware] JWT_SECRET not configured. Authentication is DISABLED.\nProtected routes will fail. Set JWT_SECRET environment variable to enable auth."
38
+ "[Auth Middleware] Auth not initialized. Authentication is DISABLED.\nCall initializeAuth() or initialize() to enable auth."
34
39
  );
35
40
  _jwtWarningLogged = true;
36
41
  }
37
42
  return null;
38
43
  }
39
- if (secret.length < 32) {
44
+ if (authConfig.jwtSecret.length < 32) {
40
45
  logger.error(
41
46
  "[Auth Middleware] JWT_SECRET must be at least 32 characters long"
42
47
  );
@@ -44,12 +49,11 @@ function getJWTManager() {
44
49
  }
45
50
  _jwtManager = new JWTManager(
46
51
  {
47
- secret,
48
- accessTokenExpiry: process.env.JWT_EXPIRES_IN || "7d",
49
- refreshTokenExpiry: process.env.JWT_REFRESH_TOKEN_EXPIRES_IN || "30d",
52
+ secret: authConfig.jwtSecret,
53
+ accessTokenExpiry: authConfig.accessTokenExpiry,
54
+ refreshTokenExpiry: authConfig.refreshTokenExpiry,
50
55
  algorithm: "HS256"
51
56
  },
52
- // Winston logger for middleware
53
57
  {
54
58
  debug: (msg, meta) => logger.debug(`[Auth] ${msg}`, meta),
55
59
  info: (msg, meta) => logger.info(`[Auth] ${msg}`, meta),
@@ -58,7 +62,7 @@ function getJWTManager() {
58
62
  }
59
63
  );
60
64
  logger.info(
61
- `[Auth Middleware] \u2705 Initialized - Access: ${process.env.JWT_EXPIRES_IN || "7d"}, Refresh: ${process.env.JWT_REFRESH_TOKEN_EXPIRES_IN || "30d"}`
65
+ `[Auth Middleware] \u2705 Initialized - Access: ${authConfig.accessTokenExpiry}, Refresh: ${authConfig.refreshTokenExpiry}`
62
66
  );
63
67
  }
64
68
  return _jwtManager;
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  InMemoryCacheManager
3
- } from "./chunk-Y6IHEA3Q.js";
3
+ } from "./chunk-XZ4HMXSK.js";
4
4
  import {
5
5
  isRedisGloballyDisabled,
6
6
  notifyRedisError
7
- } from "./chunk-I5PCM2JQ.js";
8
- import {
9
- getCacheFallbackConfig
10
- } from "./chunk-N4XYQB2G.js";
7
+ } from "./chunk-PU2LFTI5.js";
11
8
  import {
12
9
  logger
13
- } from "./chunk-5A2L6TXD.js";
10
+ } from "./chunk-SNNXLA5F.js";
11
+ import {
12
+ getCacheFallbackConfig
13
+ } from "./chunk-X2QSMX3B.js";
14
14
  import {
15
15
  __spreadValues
16
16
  } from "./chunk-ORMEWXMH.js";
@@ -1,15 +1,15 @@
1
+ import {
2
+ IPApiProvider
3
+ } from "./chunk-DEEJBDJE.js";
1
4
  import {
2
5
  IPApiCoProvider
3
6
  } from "./chunk-VSGKVZB4.js";
4
7
  import {
5
8
  IPGeolocationProvider
6
- } from "./chunk-DH2ZHGW2.js";
9
+ } from "./chunk-MVH5ZPFD.js";
7
10
  import {
8
11
  MaxMindProvider
9
- } from "./chunk-4NWJ3WCZ.js";
10
- import {
11
- IPApiProvider
12
- } from "./chunk-DEEJBDJE.js";
12
+ } from "./chunk-Q7NIAITA.js";
13
13
 
14
14
  // src/geolocation/providers/index.ts
15
15
  var GeoIPProviderFactory = class {
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  getCacheManager,
3
3
  getEffectiveCacheBackend
4
- } from "./chunk-YVF4RXOK.js";
4
+ } from "./chunk-3GKJ763I.js";
5
5
  import {
6
6
  getCacheConfig,
7
7
  getCacheTTL
8
- } from "./chunk-HCTNZM7D.js";
9
- import {
10
- isCacheEnabled
11
- } from "./chunk-N4XYQB2G.js";
8
+ } from "./chunk-C3WPAWID.js";
12
9
  import {
13
10
  logger
14
- } from "./chunk-5A2L6TXD.js";
11
+ } from "./chunk-SNNXLA5F.js";
12
+ import {
13
+ isCacheEnabled
14
+ } from "./chunk-X2QSMX3B.js";
15
15
 
16
16
  // src/cache/cache-wrapper.ts
17
17
  function getCacheBackendLabel() {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-6WVKLXVT.js";
4
+ } from "./chunk-JGGGHEBC.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-5A2L6TXD.js";
7
+ } from "./chunk-SNNXLA5F.js";
8
8
 
9
9
  // src/system/disk.ts
10
10
  async function getDiskInfo() {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getENV,
3
3
  isCacheEnabled
4
- } from "./chunk-N4XYQB2G.js";
4
+ } from "./chunk-X2QSMX3B.js";
5
5
 
6
6
  // src/cache/cache-config.ts
7
7
  var getCacheConfig = {
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  AppError
3
3
  } from "./chunk-KXXROUA5.js";
4
- import {
5
- ERROR_CODES,
6
- formatErrorMessage
7
- } from "./chunk-SNVGJPPX.js";
8
4
  import {
9
5
  logApiRequest,
10
6
  logApiResponse,
11
7
  logger
12
- } from "./chunk-5A2L6TXD.js";
8
+ } from "./chunk-SNNXLA5F.js";
9
+ import {
10
+ ERROR_CODES,
11
+ formatErrorMessage
12
+ } from "./chunk-SNVGJPPX.js";
13
13
 
14
14
  // src/utils/error-processor.ts
15
15
  import { NextResponse } from "next/server";
@@ -1,22 +1,25 @@
1
1
  import {
2
2
  AUTH_ERROR_CODE_MAP
3
- } from "./chunk-JWZSWMOM.js";
3
+ } from "./chunk-HKJCBV3H.js";
4
+ import {
5
+ AppError
6
+ } from "./chunk-KXXROUA5.js";
4
7
  import {
5
8
  getErrorMessage
6
9
  } from "./chunk-Y2JYA2AR.js";
7
10
  import {
8
- AppError
9
- } from "./chunk-KXXROUA5.js";
11
+ logger
12
+ } from "./chunk-SNNXLA5F.js";
10
13
  import {
11
- ERROR_CODES,
12
- classifyError
13
- } from "./chunk-SNVGJPPX.js";
14
+ getCommonConfig
15
+ } from "./chunk-5MBKG2ZD.js";
14
16
  import {
15
17
  AuthError
16
18
  } from "./chunk-AIH3F7JV.js";
17
19
  import {
18
- logger
19
- } from "./chunk-5A2L6TXD.js";
20
+ ERROR_CODES,
21
+ classifyError
22
+ } from "./chunk-SNVGJPPX.js";
20
23
  import {
21
24
  __spreadValues
22
25
  } from "./chunk-ORMEWXMH.js";
@@ -73,7 +76,12 @@ var errorHandlerMiddleware = async (context, next) => {
73
76
  }
74
77
  const classified = error instanceof Error ? classifyError(error) : ERROR_CODES.INTERNAL_SERVER_ERROR;
75
78
  logger.error("[ErrorHandler] Unexpected error:", error);
76
- const isProduction = process.env.NODE_ENV === "production";
79
+ let isProduction = false;
80
+ try {
81
+ isProduction = getCommonConfig().nodeEnv === "production";
82
+ } catch (e) {
83
+ isProduction = false;
84
+ }
77
85
  const safeMessage = isProduction ? classified.message : error instanceof Error ? error.message : "Unknown error";
78
86
  return createErrorResponse(
79
87
  classified.code,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getCacheConfig
3
- } from "./chunk-HCTNZM7D.js";
3
+ } from "./chunk-C3WPAWID.js";
4
4
  import {
5
5
  getENV
6
- } from "./chunk-N4XYQB2G.js";
6
+ } from "./chunk-X2QSMX3B.js";
7
7
 
8
8
  // src/cache/noop-cache-manager.ts
9
9
  var NoopCacheManager = class {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-5A2L6TXD.js";
3
+ } from "./chunk-SNNXLA5F.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  cache,
3
3
  geoCache
4
- } from "./chunk-YVF4RXOK.js";
4
+ } from "./chunk-3GKJ763I.js";
5
5
 
6
6
  // src/cache/cache-invalidation.ts
7
7
  var invalidateCache = {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-6WVKLXVT.js";
4
+ } from "./chunk-JGGGHEBC.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-5A2L6TXD.js";
7
+ } from "./chunk-SNNXLA5F.js";
8
8
 
9
9
  // src/system/cpu.ts
10
10
  import os from "os";
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  AppError
3
3
  } from "./chunk-KXXROUA5.js";
4
+ import {
5
+ logger
6
+ } from "./chunk-SNNXLA5F.js";
7
+ import {
8
+ AuthError
9
+ } from "./chunk-AIH3F7JV.js";
4
10
  import {
5
11
  ERROR_CODES,
6
12
  classifyError,
7
13
  formatErrorMessage,
8
14
  getHttpStatus
9
15
  } from "./chunk-SNVGJPPX.js";
10
- import {
11
- AuthError
12
- } from "./chunk-AIH3F7JV.js";
13
- import {
14
- logger
15
- } from "./chunk-5A2L6TXD.js";
16
16
  import {
17
17
  __spreadProps,
18
18
  __spreadValues
@@ -0,0 +1,42 @@
1
+ import {
2
+ configWarn
3
+ } from "./chunk-K25ICPU4.js";
4
+ import {
5
+ ConfigurationError
6
+ } from "./chunk-2QH66EVQ.js";
7
+
8
+ // src/auth/config.ts
9
+ var _config = null;
10
+ function initializeAuth(config) {
11
+ var _a, _b;
12
+ if (_config) return;
13
+ if (!config.jwtSecret) {
14
+ throw new ConfigurationError("Auth", "jwtSecret is required");
15
+ }
16
+ if (!config.accessTokenExpiry) {
17
+ configWarn("Auth", "accessTokenExpiry not provided, using default: 7d");
18
+ }
19
+ if (!config.refreshTokenExpiry) {
20
+ configWarn("Auth", "refreshTokenExpiry not provided, using default: 30d");
21
+ }
22
+ _config = {
23
+ jwtSecret: config.jwtSecret,
24
+ accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : "7d",
25
+ refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : "30d"
26
+ };
27
+ }
28
+ function getAuthConfig() {
29
+ if (!_config) {
30
+ throw new ConfigurationError("Auth", "Not initialized. Call initializeAuth() first.");
31
+ }
32
+ return _config;
33
+ }
34
+ function resetAuth() {
35
+ _config = null;
36
+ }
37
+
38
+ export {
39
+ initializeAuth,
40
+ getAuthConfig,
41
+ resetAuth
42
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-5A2L6TXD.js";
3
+ } from "./chunk-SNNXLA5F.js";
4
4
 
5
5
  // src/system/utils.ts
6
6
  import { exec } from "child_process";
@@ -0,0 +1,40 @@
1
+ import {
2
+ configWarn
3
+ } from "./chunk-K25ICPU4.js";
4
+ import {
5
+ ConfigurationError
6
+ } from "./chunk-2QH66EVQ.js";
7
+
8
+ // src/middleware/cors-config.ts
9
+ var _config = null;
10
+ function initializeCors(config) {
11
+ if (_config) return;
12
+ if (!config.allowedOrigins) {
13
+ throw new ConfigurationError("CORS", "allowedOrigins is required");
14
+ }
15
+ if (config.allowedOrigins.length === 0) {
16
+ throw new ConfigurationError("CORS", "allowedOrigins must not be empty");
17
+ }
18
+ if (config.baseUrl === void 0) {
19
+ configWarn("CORS", "baseUrl not provided");
20
+ }
21
+ _config = {
22
+ allowedOrigins: [...config.allowedOrigins],
23
+ baseUrl: config.baseUrl
24
+ };
25
+ }
26
+ function getCorsConfig() {
27
+ if (!_config) {
28
+ throw new ConfigurationError("CORS", "Not initialized. Call initializeCors() first.");
29
+ }
30
+ return _config;
31
+ }
32
+ function resetCors() {
33
+ _config = null;
34
+ }
35
+
36
+ export {
37
+ initializeCors,
38
+ getCorsConfig,
39
+ resetCors
40
+ };