@withwiz/toolkit 0.2.8 → 0.3.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/config.d.ts +16 -0
- package/dist/auth/config.js +13 -0
- package/dist/auth/index.js +18 -18
- package/dist/cache/cache-config.js +6 -3
- package/dist/cache/cache-env.d.ts +11 -20
- package/dist/cache/cache-env.js +5 -6
- package/dist/cache/cache-factory.js +15 -10
- package/dist/cache/cache-invalidation.js +15 -10
- package/dist/cache/cache-redis.js +8 -3
- package/dist/cache/cache-wrapper.js +15 -10
- package/dist/cache/cache.js +32 -24
- package/dist/cache/config.d.ts +116 -0
- package/dist/cache/config.js +13 -0
- package/dist/cache/hybrid-cache-manager.js +10 -5
- package/dist/cache/index.d.ts +2 -1
- package/dist/cache/index.js +32 -24
- package/dist/cache/inmemory-cache-manager.js +6 -2
- package/dist/cache/noop-cache-manager.js +7 -4
- package/dist/cache/redis-cache-manager.js +9 -4
- package/dist/{chunk-JWZSWMOM.js → chunk-2KDLKHTO.js} +1 -1
- package/dist/chunk-2QH66EVQ.js +11 -0
- package/dist/chunk-3CBGGMIY.js +39 -0
- package/dist/{chunk-67KRDPIH.js → chunk-4HBAPPB2.js} +2 -2
- package/dist/{chunk-QMZ75GBU.js → chunk-6MI4XLWC.js} +1 -1
- package/dist/{chunk-BX5CNRVS.js → chunk-6SOQUYOU.js} +2 -2
- package/dist/{chunk-YVF4RXOK.js → chunk-7IN4WRSO.js} +15 -15
- package/dist/{chunk-I5PCM2JQ.js → chunk-AXCB7SKY.js} +4 -4
- package/dist/chunk-AYZJN32D.js +45 -0
- package/dist/{chunk-74MSBKYW.js → chunk-BDY3AOX5.js} +14 -10
- package/dist/{chunk-IT43YQND.js → chunk-BYCFXGQL.js} +20 -5
- package/dist/{chunk-QF6FH4GZ.js → chunk-CUZPD3BF.js} +5 -5
- package/dist/{chunk-JOGXLVUZ.js → chunk-E54MAI4I.js} +1 -1
- package/dist/{chunk-WEDR5GJO.js → chunk-FD2TXDTO.js} +2 -2
- package/dist/{chunk-HOMWLK62.js → chunk-FDRIFPG6.js} +2 -2
- package/dist/{chunk-AOZVTVJG.js → chunk-FPESPW6P.js} +1 -1
- package/dist/{chunk-4NWJ3WCZ.js → chunk-G5OMETUS.js} +8 -1
- package/dist/chunk-GFWGLWTS.js +48 -0
- package/dist/{chunk-5A2L6TXD.js → chunk-GQVBWZLH.js} +34 -15
- package/dist/{chunk-DH2ZHGW2.js → chunk-HHCDMWEF.js} +14 -2
- package/dist/{chunk-Y6IHEA3Q.js → chunk-J4TTSXDN.js} +3 -3
- package/dist/{chunk-WZDS4QEC.js → chunk-JOM3N4EJ.js} +1 -1
- package/dist/{chunk-WSUFD4SO.js → chunk-JR7GVCQX.js} +11 -3
- package/dist/chunk-K25ICPU4.js +8 -0
- package/dist/{chunk-T3YUJYBX.js → chunk-K3HAYBWX.js} +1 -1
- package/dist/{chunk-WDJLAZCW.js → chunk-KGHWGLED.js} +18 -3
- package/dist/{chunk-XN4YP4XO.js → chunk-KZUBO2IL.js} +5 -5
- package/dist/{chunk-3GEQQ4VL.js → chunk-LD7POV6B.js} +10 -10
- package/dist/{chunk-7KCWVRPR.js → chunk-LFQ3IQQB.js} +2 -2
- package/dist/{chunk-RPWEGUUS.js → chunk-LX2EYD74.js} +8 -8
- package/dist/{chunk-HCTNZM7D.js → chunk-O7CK3CKJ.js} +1 -1
- package/dist/chunk-OHBAELPZ.js +46 -0
- package/dist/{chunk-M5LIX3TD.js → chunk-OIRAH57Y.js} +1 -1
- package/dist/chunk-OZE5KUS3.js +50 -0
- package/dist/{chunk-NJXCFTOE.js → chunk-QVWDWROP.js} +1 -1
- package/dist/{chunk-YMIDD4YE.js → chunk-RWVGJUON.js} +6 -6
- package/dist/{chunk-6WVKLXVT.js → chunk-S5UCZ2T3.js} +1 -1
- package/dist/chunk-SFPMFVSD.js +40 -0
- package/dist/{chunk-R5OFGX3C.js → chunk-SV7X6HEN.js} +6 -6
- package/dist/chunk-TFD3DSM2.js +110 -0
- package/dist/{chunk-GCZOXUDV.js → chunk-TO5CMMQC.js} +50 -10
- package/dist/{chunk-LEWQBXN6.js → chunk-VF4EVAMV.js} +1 -1
- package/dist/chunk-WNF2RKFA.js +122 -0
- package/dist/chunk-XI4MRH5P.js +156 -0
- package/dist/components/ui/DataTable.js +5 -5
- package/dist/components/ui/data-table/DataTable.js +5 -5
- package/dist/components/ui/data-table/DataTableFilters.js +2 -2
- package/dist/components/ui/data-table/DataTableSearch.js +2 -2
- package/dist/config/common.d.ts +12 -0
- package/dist/config/common.js +13 -0
- package/dist/config/errors.d.ts +3 -0
- package/dist/config/errors.js +7 -0
- package/dist/config/warn.d.ts +4 -0
- package/dist/config/warn.js +7 -0
- package/dist/constants/index.js +13 -13
- package/dist/error/error-handler.js +6 -2
- package/dist/error/index.js +6 -2
- package/dist/geolocation/batch-processor.js +6 -2
- package/dist/geolocation/config.d.ts +14 -0
- package/dist/geolocation/config.js +13 -0
- package/dist/geolocation/index.js +13 -8
- package/dist/geolocation/providers/index.js +9 -6
- package/dist/geolocation/providers/ipgeolocation-provider.js +4 -1
- package/dist/geolocation/providers/maxmind-provider.js +4 -1
- package/dist/initialize.d.ts +18 -0
- package/dist/initialize.js +41 -0
- package/dist/logger/config.d.ts +20 -0
- package/dist/logger/config.js +13 -0
- package/dist/logger/logger.js +5 -1
- package/dist/middleware/auth.js +7 -2
- package/dist/middleware/cors-config.d.ts +14 -0
- package/dist/middleware/cors-config.js +13 -0
- package/dist/middleware/cors.js +7 -2
- package/dist/middleware/error-handler.js +7 -3
- package/dist/middleware/index.js +19 -13
- package/dist/middleware/middleware-chain.js +6 -2
- package/dist/middleware/rate-limit.js +6 -2
- package/dist/middleware/response-logger.js +6 -2
- package/dist/middleware/security.js +6 -2
- package/dist/middleware/wrappers.js +16 -10
- package/dist/storage/config.d.ts +20 -0
- package/dist/storage/config.js +13 -0
- package/dist/storage/r2-storage.d.ts +4 -0
- package/dist/storage/r2-storage.js +19 -10
- package/dist/system/cpu.js +7 -3
- package/dist/system/disk.js +7 -3
- package/dist/system/environment.js +11 -3
- package/dist/system/health-check.js +9 -3
- package/dist/system/index.js +18 -10
- package/dist/system/memory.js +7 -3
- package/dist/system/network.js +7 -3
- package/dist/system/utils.js +6 -2
- package/dist/types/env.d.ts +12 -2
- package/dist/utils/cors.js +5 -1
- package/dist/utils/csv-export.js +6 -2
- package/dist/utils/error-processor.js +6 -2
- package/dist/utils/index.js +23 -18
- package/package.json +10 -1
- package/dist/chunk-N4XYQB2G.js +0 -193
- package/dist/chunk-OFPRBEO6.js +0 -93
- package/dist/{chunk-TH45RVP7.js → chunk-KHYY4KCV.js} +3 -3
- package/dist/{chunk-EBUEBEJX.js → chunk-QMCOX3DP.js} +0 -0
- package/dist/{chunk-X2UP5PNN.js → chunk-SEZJN4TC.js} +3 -3
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
InMemoryCacheManager
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-J4TTSXDN.js";
|
|
4
|
+
import "../chunk-GQVBWZLH.js";
|
|
4
5
|
import "../chunk-SS56XFLI.js";
|
|
5
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-OHBAELPZ.js";
|
|
7
|
+
import "../chunk-SFPMFVSD.js";
|
|
8
|
+
import "../chunk-K25ICPU4.js";
|
|
9
|
+
import "../chunk-2QH66EVQ.js";
|
|
6
10
|
import "../chunk-ORMEWXMH.js";
|
|
7
11
|
export {
|
|
8
12
|
InMemoryCacheManager
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NoopCacheManager
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-FDRIFPG6.js";
|
|
4
|
+
import "../chunk-O7CK3CKJ.js";
|
|
5
|
+
import "../chunk-XI4MRH5P.js";
|
|
6
|
+
import "../chunk-SFPMFVSD.js";
|
|
7
|
+
import "../chunk-TFD3DSM2.js";
|
|
8
|
+
import "../chunk-K25ICPU4.js";
|
|
9
|
+
import "../chunk-2QH66EVQ.js";
|
|
7
10
|
import "../chunk-IQQKKUAV.js";
|
|
8
11
|
import "../chunk-ORMEWXMH.js";
|
|
9
12
|
export {
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RedisCacheManager
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-KZUBO2IL.js";
|
|
4
|
+
import "../chunk-AXCB7SKY.js";
|
|
5
|
+
import "../chunk-GQVBWZLH.js";
|
|
6
|
+
import "../chunk-OHBAELPZ.js";
|
|
7
|
+
import "../chunk-XI4MRH5P.js";
|
|
8
|
+
import "../chunk-SFPMFVSD.js";
|
|
9
|
+
import "../chunk-TFD3DSM2.js";
|
|
10
|
+
import "../chunk-K25ICPU4.js";
|
|
11
|
+
import "../chunk-2QH66EVQ.js";
|
|
7
12
|
import "../chunk-IQQKKUAV.js";
|
|
8
13
|
import "../chunk-ORMEWXMH.js";
|
|
9
14
|
export {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configWarn
|
|
3
|
+
} from "./chunk-K25ICPU4.js";
|
|
4
|
+
import {
|
|
5
|
+
ConfigurationError
|
|
6
|
+
} from "./chunk-2QH66EVQ.js";
|
|
7
|
+
|
|
8
|
+
// src/geolocation/config.ts
|
|
9
|
+
var GLOBAL_KEY = "__withwiz_geolocation_config";
|
|
10
|
+
function getConfig() {
|
|
11
|
+
var _a;
|
|
12
|
+
return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
|
|
13
|
+
}
|
|
14
|
+
function setConfig(config) {
|
|
15
|
+
globalThis[GLOBAL_KEY] = config;
|
|
16
|
+
}
|
|
17
|
+
function initializeGeolocation(config) {
|
|
18
|
+
if (getConfig()) return;
|
|
19
|
+
if (!config.ipgeolocationApiKey) configWarn("Geolocation", "ipgeolocationApiKey not provided, IPGeolocation provider will be unavailable");
|
|
20
|
+
if (!config.maxmindLicenseKey) configWarn("Geolocation", "maxmindLicenseKey not provided, MaxMind provider will be unavailable");
|
|
21
|
+
setConfig({
|
|
22
|
+
ipgeolocationApiKey: config.ipgeolocationApiKey,
|
|
23
|
+
maxmindLicenseKey: config.maxmindLicenseKey
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function getGeolocationConfig() {
|
|
27
|
+
const config = getConfig();
|
|
28
|
+
if (!config) throw new ConfigurationError("Geolocation", "Not initialized. Call initializeGeolocation() first.");
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
31
|
+
function resetGeolocation() {
|
|
32
|
+
globalThis[GLOBAL_KEY] = void 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
initializeGeolocation,
|
|
37
|
+
getGeolocationConfig,
|
|
38
|
+
resetGeolocation
|
|
39
|
+
};
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
formatBytesPerSec,
|
|
4
4
|
runCommand,
|
|
5
5
|
runMacCommand
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S5UCZ2T3.js";
|
|
7
7
|
import {
|
|
8
8
|
logger
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GQVBWZLH.js";
|
|
10
10
|
|
|
11
11
|
// src/system/network.ts
|
|
12
12
|
async function getNetworkInfo() {
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HybridCacheManager
|
|
3
|
-
} from "./chunk-R5OFGX3C.js";
|
|
4
|
-
import {
|
|
5
|
-
InMemoryCacheManager
|
|
6
|
-
} from "./chunk-Y6IHEA3Q.js";
|
|
7
1
|
import {
|
|
8
2
|
NoopCacheManager
|
|
9
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FDRIFPG6.js";
|
|
10
4
|
import {
|
|
11
5
|
RedisCacheManager
|
|
12
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KZUBO2IL.js";
|
|
13
7
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
8
|
+
HybridCacheManager
|
|
9
|
+
} from "./chunk-SV7X6HEN.js";
|
|
10
|
+
import {
|
|
11
|
+
InMemoryCacheManager
|
|
12
|
+
} from "./chunk-J4TTSXDN.js";
|
|
16
13
|
import {
|
|
17
14
|
isRedisAvailableNow,
|
|
18
15
|
isRedisGloballyDisabled
|
|
19
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-AXCB7SKY.js";
|
|
17
|
+
import {
|
|
18
|
+
logger
|
|
19
|
+
} from "./chunk-GQVBWZLH.js";
|
|
20
|
+
import {
|
|
21
|
+
getCacheConfig
|
|
22
|
+
} from "./chunk-O7CK3CKJ.js";
|
|
20
23
|
import {
|
|
21
24
|
getENV,
|
|
22
25
|
isCacheEnabled
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import {
|
|
25
|
-
logger
|
|
26
|
-
} from "./chunk-5A2L6TXD.js";
|
|
26
|
+
} from "./chunk-XI4MRH5P.js";
|
|
27
27
|
|
|
28
28
|
// src/cache/cache-factory.ts
|
|
29
29
|
function getInMemoryConfig() {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-GQVBWZLH.js";
|
|
1
4
|
import {
|
|
2
5
|
getCacheFallbackConfig,
|
|
3
6
|
getConfig,
|
|
4
7
|
getEnv,
|
|
5
8
|
isCacheEnabled,
|
|
6
9
|
validateRedisEnvironment
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
logger
|
|
10
|
-
} from "./chunk-5A2L6TXD.js";
|
|
10
|
+
} from "./chunk-XI4MRH5P.js";
|
|
11
11
|
|
|
12
12
|
// src/cache/cache-redis.ts
|
|
13
13
|
import { Redis } from "@upstash/redis";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configWarn
|
|
3
|
+
} from "./chunk-K25ICPU4.js";
|
|
4
|
+
import {
|
|
5
|
+
ConfigurationError
|
|
6
|
+
} from "./chunk-2QH66EVQ.js";
|
|
7
|
+
|
|
8
|
+
// src/storage/config.ts
|
|
9
|
+
var GLOBAL_KEY = "__withwiz_storage_config";
|
|
10
|
+
function getConfig() {
|
|
11
|
+
var _a;
|
|
12
|
+
return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
|
|
13
|
+
}
|
|
14
|
+
function setConfig(config) {
|
|
15
|
+
globalThis[GLOBAL_KEY] = config;
|
|
16
|
+
}
|
|
17
|
+
function initializeStorage(config) {
|
|
18
|
+
if (getConfig()) return;
|
|
19
|
+
if (!config.accountId) throw new ConfigurationError("Storage", "accountId is required");
|
|
20
|
+
if (!config.accessKeyId) throw new ConfigurationError("Storage", "accessKeyId is required");
|
|
21
|
+
if (!config.secretAccessKey) throw new ConfigurationError("Storage", "secretAccessKey is required");
|
|
22
|
+
if (!config.bucketName) throw new ConfigurationError("Storage", "bucketName is required");
|
|
23
|
+
if (config.publicUrl === void 0) configWarn("Storage", "publicUrl not provided");
|
|
24
|
+
setConfig({
|
|
25
|
+
accountId: config.accountId,
|
|
26
|
+
accessKeyId: config.accessKeyId,
|
|
27
|
+
secretAccessKey: config.secretAccessKey,
|
|
28
|
+
bucketName: config.bucketName,
|
|
29
|
+
publicUrl: config.publicUrl
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function getStorageConfig() {
|
|
33
|
+
const config = getConfig();
|
|
34
|
+
if (!config) throw new ConfigurationError("Storage", "Not initialized. Call initializeStorage() first.");
|
|
35
|
+
return config;
|
|
36
|
+
}
|
|
37
|
+
function resetStorage() {
|
|
38
|
+
globalThis[GLOBAL_KEY] = void 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
initializeStorage,
|
|
43
|
+
getStorageConfig,
|
|
44
|
+
resetStorage
|
|
45
|
+
};
|
|
@@ -4,12 +4,15 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
ERROR_CODES
|
|
6
6
|
} from "./chunk-SNVGJPPX.js";
|
|
7
|
+
import {
|
|
8
|
+
getAuthConfig
|
|
9
|
+
} from "./chunk-OZE5KUS3.js";
|
|
7
10
|
import {
|
|
8
11
|
JWTManager
|
|
9
12
|
} from "./chunk-2ATBAIRL.js";
|
|
10
13
|
import {
|
|
11
14
|
logger
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GQVBWZLH.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
|
-
|
|
30
|
-
|
|
32
|
+
let authConfig;
|
|
33
|
+
try {
|
|
34
|
+
authConfig = getAuthConfig();
|
|
35
|
+
} catch (e) {
|
|
31
36
|
if (!_jwtWarningLogged) {
|
|
32
37
|
logger.warn(
|
|
33
|
-
"[Auth Middleware]
|
|
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 (
|
|
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:
|
|
49
|
-
refreshTokenExpiry:
|
|
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: ${
|
|
65
|
+
`[Auth Middleware] \u2705 Initialized - Access: ${authConfig.accessTokenExpiry}, Refresh: ${authConfig.refreshTokenExpiry}`
|
|
62
66
|
);
|
|
63
67
|
}
|
|
64
68
|
return _jwtManager;
|
|
@@ -4,13 +4,17 @@ import {
|
|
|
4
4
|
} from "./chunk-OIVXOT2X.js";
|
|
5
5
|
import {
|
|
6
6
|
getPlatform
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-S5UCZ2T3.js";
|
|
8
8
|
import {
|
|
9
9
|
logger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GQVBWZLH.js";
|
|
11
|
+
import {
|
|
12
|
+
getResolvedCacheConfig
|
|
13
|
+
} from "./chunk-TFD3DSM2.js";
|
|
11
14
|
|
|
12
15
|
// src/system/health-check.ts
|
|
13
16
|
async function checkServiceHealth(prismaClient) {
|
|
17
|
+
var _a, _b;
|
|
14
18
|
const platform = getPlatform();
|
|
15
19
|
const services = [];
|
|
16
20
|
if (prismaClient) {
|
|
@@ -53,9 +57,20 @@ async function checkServiceHealth(prismaClient) {
|
|
|
53
57
|
}
|
|
54
58
|
try {
|
|
55
59
|
const redisStart = Date.now();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
let cacheEnabled = false;
|
|
61
|
+
try {
|
|
62
|
+
cacheEnabled = getResolvedCacheConfig().enabled;
|
|
63
|
+
} catch (e) {
|
|
64
|
+
cacheEnabled = false;
|
|
65
|
+
}
|
|
66
|
+
let redisUrl;
|
|
67
|
+
let redisToken;
|
|
68
|
+
try {
|
|
69
|
+
const cacheConfig = getResolvedCacheConfig();
|
|
70
|
+
redisUrl = (_a = cacheConfig.redis) == null ? void 0 : _a.url;
|
|
71
|
+
redisToken = (_b = cacheConfig.redis) == null ? void 0 : _b.token;
|
|
72
|
+
} catch (e) {
|
|
73
|
+
}
|
|
59
74
|
if (!cacheEnabled) {
|
|
60
75
|
services.push({
|
|
61
76
|
name: "Redis",
|
|
@@ -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-
|
|
9
|
+
} from "./chunk-HHCDMWEF.js";
|
|
7
10
|
import {
|
|
8
11
|
MaxMindProvider
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
IPApiProvider
|
|
12
|
-
} from "./chunk-DEEJBDJE.js";
|
|
12
|
+
} from "./chunk-G5OMETUS.js";
|
|
13
13
|
|
|
14
14
|
// src/geolocation/providers/index.ts
|
|
15
15
|
var GeoIPProviderFactory = class {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseGeoIPProvider
|
|
3
3
|
} from "./chunk-AHDPGRXS.js";
|
|
4
|
+
import {
|
|
5
|
+
getGeolocationConfig
|
|
6
|
+
} from "./chunk-3CBGGMIY.js";
|
|
4
7
|
|
|
5
8
|
// src/geolocation/providers/maxmind-provider.ts
|
|
6
9
|
var MaxMindProvider = class extends BaseGeoIPProvider {
|
|
@@ -19,7 +22,11 @@ var MaxMindProvider = class extends BaseGeoIPProvider {
|
|
|
19
22
|
return null;
|
|
20
23
|
}
|
|
21
24
|
isAvailable() {
|
|
22
|
-
|
|
25
|
+
try {
|
|
26
|
+
return !!getGeolocationConfig().maxmindLicenseKey;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
31
|
};
|
|
25
32
|
|
|
@@ -0,0 +1,48 @@
|
|
|
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 GLOBAL_KEY = "__withwiz_cors_config";
|
|
10
|
+
function getConfig() {
|
|
11
|
+
var _a;
|
|
12
|
+
return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
|
|
13
|
+
}
|
|
14
|
+
function setConfig(config) {
|
|
15
|
+
globalThis[GLOBAL_KEY] = config;
|
|
16
|
+
}
|
|
17
|
+
function initializeCors(config) {
|
|
18
|
+
if (getConfig()) return;
|
|
19
|
+
if (!config.allowedOrigins) {
|
|
20
|
+
throw new ConfigurationError("CORS", "allowedOrigins is required");
|
|
21
|
+
}
|
|
22
|
+
if (config.allowedOrigins.length === 0) {
|
|
23
|
+
throw new ConfigurationError("CORS", "allowedOrigins must not be empty");
|
|
24
|
+
}
|
|
25
|
+
if (config.baseUrl === void 0) {
|
|
26
|
+
configWarn("CORS", "baseUrl not provided");
|
|
27
|
+
}
|
|
28
|
+
setConfig({
|
|
29
|
+
allowedOrigins: [...config.allowedOrigins],
|
|
30
|
+
baseUrl: config.baseUrl
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function getCorsConfig() {
|
|
34
|
+
const config = getConfig();
|
|
35
|
+
if (!config) {
|
|
36
|
+
throw new ConfigurationError("CORS", "Not initialized. Call initializeCors() first.");
|
|
37
|
+
}
|
|
38
|
+
return config;
|
|
39
|
+
}
|
|
40
|
+
function resetCors() {
|
|
41
|
+
globalThis[GLOBAL_KEY] = void 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
initializeCors,
|
|
46
|
+
getCorsConfig,
|
|
47
|
+
resetCors
|
|
48
|
+
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getLoggerConfig
|
|
3
|
+
} from "./chunk-OHBAELPZ.js";
|
|
4
|
+
import {
|
|
5
|
+
getCommonConfig
|
|
6
|
+
} from "./chunk-SFPMFVSD.js";
|
|
1
7
|
import {
|
|
2
8
|
__spreadProps,
|
|
3
9
|
__spreadValues
|
|
@@ -14,14 +20,19 @@ if (typeof process !== "undefined" && process.setMaxListeners) {
|
|
|
14
20
|
}
|
|
15
21
|
}
|
|
16
22
|
var { combine, timestamp, printf, colorize } = winston.format;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
function getLogConfig() {
|
|
24
|
+
try {
|
|
25
|
+
return getLoggerConfig();
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return {
|
|
28
|
+
level: "info",
|
|
29
|
+
dir: "./logs",
|
|
30
|
+
file: "app.log",
|
|
31
|
+
fileEnabled: true,
|
|
32
|
+
consoleEnabled: true
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
25
36
|
var colors = {
|
|
26
37
|
error: "red",
|
|
27
38
|
warn: "yellow",
|
|
@@ -30,12 +41,19 @@ var colors = {
|
|
|
30
41
|
debug: "blue"
|
|
31
42
|
};
|
|
32
43
|
winston.addColors(colors);
|
|
33
|
-
var isTestEnv =
|
|
44
|
+
var isTestEnv = (() => {
|
|
45
|
+
try {
|
|
46
|
+
return getCommonConfig().nodeEnv === "test";
|
|
47
|
+
} catch (e) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
})() || process.env.VITEST !== void 0 || process.env.JEST_WORKER_ID !== void 0;
|
|
34
51
|
var isBuildTime = process.env.NEXT_PHASE === "phase-production-build" || process.argv.some((arg) => arg.includes("build"));
|
|
35
52
|
var canWriteToLogDir = (() => {
|
|
36
53
|
if (isTestEnv || isBuildTime) return false;
|
|
37
54
|
try {
|
|
38
|
-
const
|
|
55
|
+
const cfg = getLogConfig();
|
|
56
|
+
const logDir = cfg.dir;
|
|
39
57
|
if (fs.existsSync(logDir)) {
|
|
40
58
|
fs.accessSync(logDir, fs.constants.W_OK);
|
|
41
59
|
return true;
|
|
@@ -46,10 +64,10 @@ var canWriteToLogDir = (() => {
|
|
|
46
64
|
return false;
|
|
47
65
|
}
|
|
48
66
|
})();
|
|
49
|
-
var fileLoggingEnabled = !isTestEnv && !isBuildTime && canWriteToLogDir &&
|
|
50
|
-
var consoleLoggingEnabled =
|
|
67
|
+
var fileLoggingEnabled = !isTestEnv && !isBuildTime && canWriteToLogDir && getLogConfig().fileEnabled;
|
|
68
|
+
var consoleLoggingEnabled = getLogConfig().consoleEnabled;
|
|
51
69
|
var datePatternString = "YYYY-MM-DD";
|
|
52
|
-
var logLevel =
|
|
70
|
+
var logLevel = getLogConfig().level;
|
|
53
71
|
var transports = [];
|
|
54
72
|
var logFormat = combine(
|
|
55
73
|
timestamp({ format: "YYYY-MM-DD HH:mm:ss:ms" }),
|
|
@@ -121,9 +139,10 @@ if (consoleLoggingEnabled) {
|
|
|
121
139
|
);
|
|
122
140
|
}
|
|
123
141
|
if (fileLoggingEnabled) {
|
|
142
|
+
const cfg = getLogConfig();
|
|
124
143
|
transports.push(
|
|
125
144
|
new DailyRotateFile({
|
|
126
|
-
filename:
|
|
145
|
+
filename: `${cfg.dir}/${cfg.file.replace(/\.log$/, "")}-%DATE%.log`,
|
|
127
146
|
zippedArchive: true,
|
|
128
147
|
maxFiles: "14d",
|
|
129
148
|
// Keep for 14 days
|
|
@@ -131,7 +150,7 @@ if (fileLoggingEnabled) {
|
|
|
131
150
|
level: logLevel,
|
|
132
151
|
handleExceptions: true,
|
|
133
152
|
json: false,
|
|
134
|
-
dirname:
|
|
153
|
+
dirname: cfg.dir
|
|
135
154
|
})
|
|
136
155
|
);
|
|
137
156
|
}
|
|
@@ -2,6 +2,9 @@ import {
|
|
|
2
2
|
BaseGeoIPProvider,
|
|
3
3
|
truncateString
|
|
4
4
|
} from "./chunk-AHDPGRXS.js";
|
|
5
|
+
import {
|
|
6
|
+
getGeolocationConfig
|
|
7
|
+
} from "./chunk-3CBGGMIY.js";
|
|
5
8
|
|
|
6
9
|
// src/geolocation/providers/ipgeolocation-provider.ts
|
|
7
10
|
var IPGeolocationProvider = class extends BaseGeoIPProvider {
|
|
@@ -14,7 +17,12 @@ var IPGeolocationProvider = class extends BaseGeoIPProvider {
|
|
|
14
17
|
}
|
|
15
18
|
// 3초 타임아웃
|
|
16
19
|
url(ip) {
|
|
17
|
-
|
|
20
|
+
let apiKey;
|
|
21
|
+
try {
|
|
22
|
+
apiKey = getGeolocationConfig().ipgeolocationApiKey;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
18
26
|
if (!apiKey) return "";
|
|
19
27
|
return `https://api.ipgeolocation.io/ipgeo?apiKey=${apiKey}&ip=${ip}`;
|
|
20
28
|
}
|
|
@@ -44,7 +52,11 @@ var IPGeolocationProvider = class extends BaseGeoIPProvider {
|
|
|
44
52
|
return null;
|
|
45
53
|
}
|
|
46
54
|
isAvailable() {
|
|
47
|
-
|
|
55
|
+
try {
|
|
56
|
+
return !!getGeolocationConfig().ipgeolocationApiKey;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
48
60
|
}
|
|
49
61
|
};
|
|
50
62
|
|