@exyconn/common 2.1.0 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +969 -261
  2. package/dist/client/hooks/index.d.mts +1042 -0
  3. package/dist/client/hooks/index.d.ts +1042 -0
  4. package/dist/client/hooks/index.js +2276 -0
  5. package/dist/client/hooks/index.js.map +1 -0
  6. package/dist/client/hooks/index.mjs +2217 -0
  7. package/dist/client/hooks/index.mjs.map +1 -0
  8. package/dist/client/http/index.d.mts +217 -49
  9. package/dist/client/http/index.d.ts +217 -49
  10. package/dist/client/http/index.js +473 -94
  11. package/dist/client/http/index.js.map +1 -1
  12. package/dist/client/http/index.mjs +441 -84
  13. package/dist/client/http/index.mjs.map +1 -1
  14. package/dist/client/index.d.mts +6 -4
  15. package/dist/client/index.d.ts +6 -4
  16. package/dist/client/index.js +481 -319
  17. package/dist/client/index.js.map +1 -1
  18. package/dist/client/index.mjs +449 -290
  19. package/dist/client/index.mjs.map +1 -1
  20. package/dist/client/utils/index.d.mts +3 -279
  21. package/dist/client/utils/index.d.ts +3 -279
  22. package/dist/client/web/index.d.mts +1461 -0
  23. package/dist/client/web/index.d.ts +1461 -0
  24. package/dist/client/web/index.js +2681 -0
  25. package/dist/client/web/index.js.map +1 -0
  26. package/dist/client/web/index.mjs +2618 -0
  27. package/dist/client/web/index.mjs.map +1 -0
  28. package/dist/data/brand-identity.d.mts +149 -0
  29. package/dist/data/brand-identity.d.ts +149 -0
  30. package/dist/data/brand-identity.js +235 -0
  31. package/dist/data/brand-identity.js.map +1 -0
  32. package/dist/data/brand-identity.mjs +220 -0
  33. package/dist/data/brand-identity.mjs.map +1 -0
  34. package/dist/data/countries.d.mts +61 -0
  35. package/dist/data/countries.d.ts +61 -0
  36. package/dist/data/countries.js +987 -0
  37. package/dist/data/countries.js.map +1 -0
  38. package/dist/data/countries.mjs +971 -0
  39. package/dist/data/countries.mjs.map +1 -0
  40. package/dist/data/currencies.d.mts +19 -0
  41. package/dist/data/currencies.d.ts +19 -0
  42. package/dist/data/currencies.js +162 -0
  43. package/dist/data/currencies.js.map +1 -0
  44. package/dist/data/currencies.mjs +153 -0
  45. package/dist/data/currencies.mjs.map +1 -0
  46. package/dist/data/index.d.mts +7 -0
  47. package/dist/data/index.d.ts +7 -0
  48. package/dist/data/index.js +2087 -0
  49. package/dist/data/index.js.map +1 -0
  50. package/dist/data/index.mjs +1948 -0
  51. package/dist/data/index.mjs.map +1 -0
  52. package/dist/data/phone-codes.d.mts +15 -0
  53. package/dist/data/phone-codes.d.ts +15 -0
  54. package/dist/data/phone-codes.js +219 -0
  55. package/dist/data/phone-codes.js.map +1 -0
  56. package/dist/data/phone-codes.mjs +211 -0
  57. package/dist/data/phone-codes.mjs.map +1 -0
  58. package/dist/data/regex.d.mts +287 -0
  59. package/dist/data/regex.d.ts +287 -0
  60. package/dist/data/regex.js +306 -0
  61. package/dist/data/regex.js.map +1 -0
  62. package/dist/data/regex.mjs +208 -0
  63. package/dist/data/regex.mjs.map +1 -0
  64. package/dist/data/timezones.d.mts +16 -0
  65. package/dist/data/timezones.d.ts +16 -0
  66. package/dist/data/timezones.js +98 -0
  67. package/dist/data/timezones.js.map +1 -0
  68. package/dist/data/timezones.mjs +89 -0
  69. package/dist/data/timezones.mjs.map +1 -0
  70. package/dist/index-BZf42T3R.d.mts +305 -0
  71. package/dist/index-CF0D8PGE.d.ts +305 -0
  72. package/dist/index-Ckhm_HaX.d.mts +138 -0
  73. package/dist/index-DKn4raO7.d.ts +222 -0
  74. package/dist/index-NS8dS0p9.d.mts +222 -0
  75. package/dist/index-Nqm5_lwT.d.ts +188 -0
  76. package/dist/index-br6POSyA.d.ts +138 -0
  77. package/dist/index-jBi3V6e5.d.mts +188 -0
  78. package/dist/index.d.mts +21 -580
  79. package/dist/index.d.ts +21 -580
  80. package/dist/index.js +1839 -347
  81. package/dist/index.js.map +1 -1
  82. package/dist/index.mjs +1850 -359
  83. package/dist/index.mjs.map +1 -1
  84. package/dist/packageCheck-B_qfsD6R.d.ts +280 -0
  85. package/dist/packageCheck-C2_FT_Rl.d.mts +280 -0
  86. package/dist/server/configs/index.d.mts +602 -0
  87. package/dist/server/configs/index.d.ts +602 -0
  88. package/dist/server/configs/index.js +707 -0
  89. package/dist/server/configs/index.js.map +1 -0
  90. package/dist/server/configs/index.mjs +665 -0
  91. package/dist/server/configs/index.mjs.map +1 -0
  92. package/dist/server/index.d.mts +4 -1
  93. package/dist/server/index.d.ts +4 -1
  94. package/dist/server/index.js +1330 -0
  95. package/dist/server/index.js.map +1 -1
  96. package/dist/server/index.mjs +1286 -2
  97. package/dist/server/index.mjs.map +1 -1
  98. package/dist/server/middleware/index.d.mts +283 -2
  99. package/dist/server/middleware/index.d.ts +283 -2
  100. package/dist/server/middleware/index.js +761 -0
  101. package/dist/server/middleware/index.js.map +1 -1
  102. package/dist/server/middleware/index.mjs +751 -1
  103. package/dist/server/middleware/index.mjs.map +1 -1
  104. package/dist/shared/config/index.d.mts +40 -0
  105. package/dist/shared/config/index.d.ts +40 -0
  106. package/dist/shared/config/index.js +58 -0
  107. package/dist/shared/config/index.js.map +1 -0
  108. package/dist/shared/config/index.mjs +51 -0
  109. package/dist/shared/config/index.mjs.map +1 -0
  110. package/dist/shared/constants/index.d.mts +593 -0
  111. package/dist/shared/constants/index.d.ts +593 -0
  112. package/dist/shared/constants/index.js +391 -0
  113. package/dist/shared/constants/index.js.map +1 -0
  114. package/dist/shared/constants/index.mjs +360 -0
  115. package/dist/shared/constants/index.mjs.map +1 -0
  116. package/dist/shared/index.d.mts +5 -1
  117. package/dist/shared/index.d.ts +5 -1
  118. package/dist/shared/types/index.d.mts +140 -0
  119. package/dist/shared/types/index.d.ts +140 -0
  120. package/dist/shared/types/index.js +4 -0
  121. package/dist/shared/types/index.js.map +1 -0
  122. package/dist/shared/types/index.mjs +3 -0
  123. package/dist/shared/types/index.mjs.map +1 -0
  124. package/dist/shared/utils/index.d.mts +255 -0
  125. package/dist/shared/utils/index.d.ts +255 -0
  126. package/dist/shared/utils/index.js +623 -0
  127. package/dist/shared/utils/index.js.map +1 -0
  128. package/dist/shared/utils/index.mjs +324 -0
  129. package/dist/shared/utils/index.mjs.map +1 -0
  130. package/dist/shared/validation/index.d.mts +258 -0
  131. package/dist/shared/validation/index.d.ts +258 -0
  132. package/dist/shared/validation/index.js +185 -0
  133. package/dist/shared/validation/index.js.map +1 -0
  134. package/dist/shared/validation/index.mjs +172 -0
  135. package/dist/shared/validation/index.mjs.map +1 -0
  136. package/package.json +127 -62
  137. package/dist/index-BcxL4_V4.d.ts +0 -2946
  138. package/dist/index-DEzgM15j.d.ts +0 -67
  139. package/dist/index-DNFVgQx8.d.ts +0 -1375
  140. package/dist/index-DbV04Dx8.d.mts +0 -67
  141. package/dist/index-DfqEP6Oe.d.mts +0 -1375
  142. package/dist/index-bvvCev9Q.d.mts +0 -2946
@@ -0,0 +1,602 @@
1
+ import { CorsOptions } from 'cors';
2
+ import { Options, RateLimitRequestHandler } from 'express-rate-limit';
3
+ import { Request } from 'express';
4
+
5
+ /**
6
+ * CORS configuration options
7
+ */
8
+ interface CorsConfig {
9
+ /** Allowed production origins */
10
+ productionOrigins?: string[];
11
+ /** Allowed development origins */
12
+ developmentOrigins?: string[];
13
+ /** Subdomain patterns to allow (e.g., '.exyconn.com') */
14
+ allowedSubdomains?: string[];
15
+ /** Regex patterns for origin matching */
16
+ originPatterns?: RegExp[];
17
+ /** Allow requests with no origin (mobile apps, curl) */
18
+ allowNoOrigin?: boolean;
19
+ /** Allow all origins in development */
20
+ allowAllInDev?: boolean;
21
+ /** Custom origin validator */
22
+ customValidator?: (origin: string) => boolean;
23
+ /** Enable credentials */
24
+ credentials?: boolean;
25
+ /** Allowed HTTP methods */
26
+ methods?: string[];
27
+ /** Allowed headers */
28
+ allowedHeaders?: string[];
29
+ /** Exposed headers */
30
+ exposedHeaders?: string[];
31
+ /** Preflight cache duration in seconds */
32
+ maxAge?: number;
33
+ }
34
+ /**
35
+ * Default CORS configuration
36
+ */
37
+ declare const DEFAULT_CORS_CONFIG: Required<Omit<CorsConfig, 'customValidator'>> & {
38
+ customValidator?: (origin: string) => boolean;
39
+ };
40
+ /**
41
+ * Create CORS options with custom configuration
42
+ * @param config - CORS configuration options
43
+ * @returns Express CORS options object
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * // Basic usage with production origins
48
+ * const cors = createCorsOptions({
49
+ * productionOrigins: ['https://example.com'],
50
+ * allowedSubdomains: ['.example.com'],
51
+ * });
52
+ *
53
+ * // With custom validator
54
+ * const cors = createCorsOptions({
55
+ * customValidator: (origin) => origin.includes('trusted'),
56
+ * });
57
+ * ```
58
+ */
59
+ declare const createCorsOptions: (config?: CorsConfig) => CorsOptions;
60
+ /**
61
+ * Create CORS options for a specific project/brand
62
+ * @param brandDomain - Primary domain (e.g., 'exyconn.com')
63
+ * @param additionalConfig - Additional configuration
64
+ */
65
+ declare const createBrandCorsOptions: (brandDomain: string, additionalConfig?: Partial<CorsConfig>) => CorsOptions;
66
+ /**
67
+ * Create CORS options for multiple projects
68
+ * @param domains - Array of primary domains
69
+ * @param additionalConfig - Additional configuration
70
+ */
71
+ declare const createMultiBrandCorsOptions: (domains: string[], additionalConfig?: Partial<CorsConfig>) => CorsOptions;
72
+ /**
73
+ * Exyconn preset CORS configuration
74
+ */
75
+ declare const EXYCONN_CORS_CONFIG: CorsConfig;
76
+ /**
77
+ * Strict CORS configuration (production only)
78
+ */
79
+ declare const STRICT_CORS_CONFIG: CorsConfig;
80
+ /**
81
+ * Permissive CORS configuration (development/testing)
82
+ */
83
+ declare const PERMISSIVE_CORS_CONFIG: CorsConfig;
84
+ /**
85
+ * @deprecated Use createCorsOptions() instead
86
+ */
87
+ declare const corsOptions: CorsOptions;
88
+
89
+ /**
90
+ * Rate limit tier configuration
91
+ */
92
+ interface RateLimitTierConfig {
93
+ /** Window duration in milliseconds */
94
+ windowMs: number;
95
+ /** Maximum requests allowed in window */
96
+ maxRequests: number;
97
+ /** Error message to return */
98
+ message: string;
99
+ /** Skip successful requests */
100
+ skipSuccessfulRequests?: boolean;
101
+ /** Skip failed requests */
102
+ skipFailedRequests?: boolean;
103
+ }
104
+ /**
105
+ * Rate limiter configuration options
106
+ */
107
+ interface RateLimiterConfig {
108
+ /** Standard tier - general API endpoints */
109
+ standard?: Partial<RateLimitTierConfig>;
110
+ /** Strict tier - sensitive endpoints (login, signup) */
111
+ strict?: Partial<RateLimitTierConfig>;
112
+ /** DDoS tier - global protection */
113
+ ddos?: Partial<RateLimitTierConfig>;
114
+ /** Custom tiers */
115
+ custom?: Record<string, RateLimitTierConfig>;
116
+ /** Use standard headers */
117
+ standardHeaders?: boolean;
118
+ /** Use legacy headers */
119
+ legacyHeaders?: boolean;
120
+ /** Custom key generator */
121
+ keyGenerator?: (req: Request) => string;
122
+ /** Skip certain requests */
123
+ skip?: (req: Request) => boolean;
124
+ /** Handler for when rate limit is exceeded */
125
+ handler?: Options['handler'];
126
+ }
127
+ /**
128
+ * Rate limit response format
129
+ */
130
+ interface RateLimitResponse {
131
+ status: string;
132
+ statusCode: number;
133
+ message: string;
134
+ retryAfter?: number;
135
+ }
136
+ /**
137
+ * Default rate limit tier configurations
138
+ */
139
+ declare const DEFAULT_RATE_LIMIT_TIERS: {
140
+ readonly STANDARD: {
141
+ readonly windowMs: number;
142
+ readonly maxRequests: 100;
143
+ readonly message: "Too many requests, please try again later.";
144
+ readonly skipSuccessfulRequests: false;
145
+ readonly skipFailedRequests: false;
146
+ };
147
+ readonly STRICT: {
148
+ readonly windowMs: number;
149
+ readonly maxRequests: 20;
150
+ readonly message: "Too many requests, please try again later.";
151
+ readonly skipSuccessfulRequests: false;
152
+ readonly skipFailedRequests: false;
153
+ };
154
+ readonly DDOS: {
155
+ readonly windowMs: number;
156
+ readonly maxRequests: 60;
157
+ readonly message: "Rate limit exceeded. Please slow down.";
158
+ readonly skipSuccessfulRequests: false;
159
+ readonly skipFailedRequests: false;
160
+ };
161
+ readonly VERY_STRICT: {
162
+ readonly windowMs: number;
163
+ readonly maxRequests: 5;
164
+ readonly message: "Too many attempts. Please try again in an hour.";
165
+ readonly skipSuccessfulRequests: false;
166
+ readonly skipFailedRequests: false;
167
+ };
168
+ readonly RELAXED: {
169
+ readonly windowMs: number;
170
+ readonly maxRequests: 500;
171
+ readonly message: "Rate limit exceeded.";
172
+ readonly skipSuccessfulRequests: false;
173
+ readonly skipFailedRequests: false;
174
+ };
175
+ readonly API: {
176
+ readonly windowMs: number;
177
+ readonly maxRequests: 30;
178
+ readonly message: "API rate limit exceeded.";
179
+ readonly skipSuccessfulRequests: false;
180
+ readonly skipFailedRequests: false;
181
+ };
182
+ };
183
+ /**
184
+ * Default IP-based key generator
185
+ */
186
+ declare const defaultKeyGenerator: (req: Request) => string;
187
+ /**
188
+ * Create key generator with custom prefix
189
+ */
190
+ declare const createPrefixedKeyGenerator: (prefix: string) => (req: Request) => string;
191
+ /**
192
+ * Create key generator based on user ID (for authenticated routes)
193
+ */
194
+ declare const createUserKeyGenerator: (getUserId: (req: Request) => string | undefined) => (req: Request) => string;
195
+ /**
196
+ * Create key generator based on API key
197
+ */
198
+ declare const createApiKeyGenerator: (headerName?: string) => (req: Request) => string;
199
+ /**
200
+ * Create a rate limiter with custom configuration
201
+ * @param tierConfig - Tier configuration
202
+ * @param options - Additional options
203
+ * @returns Express rate limit middleware
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * // Create custom rate limiter
208
+ * const apiLimiter = createRateLimiter({
209
+ * windowMs: 60 * 1000, // 1 minute
210
+ * maxRequests: 30,
211
+ * message: 'API rate limit exceeded',
212
+ * });
213
+ *
214
+ * // Use with user-based limiting
215
+ * const userLimiter = createRateLimiter(
216
+ * { windowMs: 60000, maxRequests: 10, message: 'Slow down!' },
217
+ * { keyGenerator: createUserKeyGenerator((req) => req.userId) }
218
+ * );
219
+ * ```
220
+ */
221
+ declare const createRateLimiter: (tierConfig: RateLimitTierConfig, options?: Partial<Omit<RateLimiterConfig, "standard" | "strict" | "ddos" | "custom">>) => RateLimitRequestHandler;
222
+ /**
223
+ * Create standard rate limiter
224
+ * @param config - Optional custom configuration
225
+ */
226
+ declare const createStandardRateLimiter: (config?: Partial<RateLimitTierConfig>, options?: Partial<Omit<RateLimiterConfig, "standard" | "strict" | "ddos" | "custom">>) => RateLimitRequestHandler;
227
+ /**
228
+ * Create strict rate limiter (for sensitive endpoints)
229
+ * @param config - Optional custom configuration
230
+ */
231
+ declare const createStrictRateLimiter: (config?: Partial<RateLimitTierConfig>, options?: Partial<Omit<RateLimiterConfig, "standard" | "strict" | "ddos" | "custom">>) => RateLimitRequestHandler;
232
+ /**
233
+ * Create DDoS protection rate limiter
234
+ * @param config - Optional custom configuration
235
+ */
236
+ declare const createDdosRateLimiter: (config?: Partial<RateLimitTierConfig>, options?: Partial<Omit<RateLimiterConfig, "standard" | "strict" | "ddos" | "custom">>) => RateLimitRequestHandler;
237
+ /**
238
+ * Create API rate limiter
239
+ * @param config - Optional custom configuration
240
+ */
241
+ declare const createApiRateLimiter: (config?: Partial<RateLimitTierConfig>, options?: Partial<Omit<RateLimiterConfig, "standard" | "strict" | "ddos" | "custom">>) => RateLimitRequestHandler;
242
+ /**
243
+ * Rate limiter builder for complex configurations
244
+ */
245
+ declare class RateLimiterBuilder {
246
+ private config;
247
+ private options;
248
+ constructor(preset?: keyof typeof DEFAULT_RATE_LIMIT_TIERS);
249
+ /**
250
+ * Set window duration
251
+ */
252
+ windowMs(ms: number): this;
253
+ /**
254
+ * Set window duration in minutes
255
+ */
256
+ windowMinutes(minutes: number): this;
257
+ /**
258
+ * Set window duration in hours
259
+ */
260
+ windowHours(hours: number): this;
261
+ /**
262
+ * Set maximum requests
263
+ */
264
+ max(requests: number): this;
265
+ /**
266
+ * Set error message
267
+ */
268
+ message(msg: string): this;
269
+ /**
270
+ * Skip successful requests
271
+ */
272
+ skipSuccessful(skip?: boolean): this;
273
+ /**
274
+ * Skip failed requests
275
+ */
276
+ skipFailed(skip?: boolean): this;
277
+ /**
278
+ * Set key generator
279
+ */
280
+ keyBy(generator: (req: Request) => string): this;
281
+ /**
282
+ * Key by IP (default)
283
+ */
284
+ keyByIp(): this;
285
+ /**
286
+ * Key by API key
287
+ */
288
+ keyByApiKey(headerName?: string): this;
289
+ /**
290
+ * Skip certain requests
291
+ */
292
+ skipWhen(predicate: (req: Request) => boolean): this;
293
+ /**
294
+ * Build the rate limiter
295
+ */
296
+ build(): RateLimitRequestHandler;
297
+ }
298
+ /**
299
+ * Create a new rate limiter builder
300
+ */
301
+ declare const rateLimiter: (preset?: keyof typeof DEFAULT_RATE_LIMIT_TIERS) => RateLimiterBuilder;
302
+ /**
303
+ * @deprecated Use DEFAULT_RATE_LIMIT_TIERS instead
304
+ */
305
+ declare const RATE_LIMIT_CONFIG: {
306
+ readonly STANDARD: {
307
+ readonly windowMs: number;
308
+ readonly maxRequests: 100;
309
+ readonly message: "Too many requests, please try again later.";
310
+ readonly skipSuccessfulRequests: false;
311
+ readonly skipFailedRequests: false;
312
+ };
313
+ readonly STRICT: {
314
+ readonly windowMs: number;
315
+ readonly maxRequests: 20;
316
+ readonly message: "Too many requests, please try again later.";
317
+ readonly skipSuccessfulRequests: false;
318
+ readonly skipFailedRequests: false;
319
+ };
320
+ readonly DDOS: {
321
+ readonly windowMs: number;
322
+ readonly maxRequests: 60;
323
+ readonly message: "Rate limit exceeded. Please slow down.";
324
+ readonly skipSuccessfulRequests: false;
325
+ readonly skipFailedRequests: false;
326
+ };
327
+ };
328
+ /**
329
+ * @deprecated Use createStandardRateLimiter() instead
330
+ */
331
+ declare const standardRateLimiter: RateLimitRequestHandler;
332
+ /**
333
+ * @deprecated Use createStrictRateLimiter() instead
334
+ */
335
+ declare const strictRateLimiter: RateLimitRequestHandler;
336
+ /**
337
+ * @deprecated Use createDdosRateLimiter() instead
338
+ */
339
+ declare const ddosProtectionLimiter: RateLimitRequestHandler;
340
+
341
+ /**
342
+ * Environment type
343
+ */
344
+ type Environment = 'development' | 'production' | 'test' | 'staging';
345
+ /**
346
+ * Log level type
347
+ */
348
+ type LogLevel = 'error' | 'warn' | 'info' | 'http' | 'debug';
349
+ /**
350
+ * Server configuration interface
351
+ */
352
+ interface ServerConfig {
353
+ /** Server name/identifier */
354
+ name: string;
355
+ /** Server version */
356
+ version: string;
357
+ /** Current environment */
358
+ environment: Environment;
359
+ /** Server port */
360
+ port: number;
361
+ /** Host binding */
362
+ host: string;
363
+ /** Base API path */
364
+ basePath: string;
365
+ /** Enable debug mode */
366
+ debug: boolean;
367
+ /** Trusted proxy settings */
368
+ trustProxy: boolean | string | number;
369
+ }
370
+ /**
371
+ * Database configuration interface
372
+ */
373
+ interface DatabaseConfig {
374
+ /** MongoDB connection URI */
375
+ uri: string;
376
+ /** Database name */
377
+ name: string;
378
+ /** Max connection pool size */
379
+ maxPoolSize: number;
380
+ /** Min connection pool size */
381
+ minPoolSize: number;
382
+ /** Socket timeout in ms */
383
+ socketTimeoutMS: number;
384
+ /** Server selection timeout in ms */
385
+ serverSelectionTimeoutMS: number;
386
+ /** Max idle time in ms */
387
+ maxIdleTimeMS: number;
388
+ /** Enable retry writes */
389
+ retryWrites: boolean;
390
+ /** Enable retry reads */
391
+ retryReads: boolean;
392
+ /** Write concern */
393
+ writeConcern: 'majority' | number;
394
+ }
395
+ /**
396
+ * JWT/Auth configuration interface
397
+ */
398
+ interface AuthConfig {
399
+ /** JWT secret key */
400
+ jwtSecret: string;
401
+ /** JWT expiration (e.g., '7d', '24h', '30m') */
402
+ jwtExpiresIn: string;
403
+ /** Refresh token expiration */
404
+ refreshTokenExpiresIn: string;
405
+ /** Enable refresh tokens */
406
+ enableRefreshTokens: boolean;
407
+ /** API key header name */
408
+ apiKeyHeader: string;
409
+ /** Organization header name */
410
+ orgHeader: string;
411
+ }
412
+ /**
413
+ * Logging configuration interface
414
+ */
415
+ interface LoggingConfig {
416
+ /** Log level */
417
+ level: LogLevel;
418
+ /** Logs directory */
419
+ logsDir: string;
420
+ /** Max log file size */
421
+ maxSize: string;
422
+ /** Max days to keep logs */
423
+ maxFiles: string;
424
+ /** Max days to keep error logs */
425
+ errorMaxFiles: string;
426
+ /** Enable console logging */
427
+ console: boolean;
428
+ /** Enable file logging */
429
+ file: boolean;
430
+ /** Enable JSON format */
431
+ json: boolean;
432
+ }
433
+ /**
434
+ * CORS origins configuration
435
+ */
436
+ interface CorsOriginsConfig {
437
+ /** Production domains */
438
+ production: string[];
439
+ /** Development domains */
440
+ development: string[];
441
+ /** Custom domain patterns (regex strings) */
442
+ patterns: string[];
443
+ }
444
+ /**
445
+ * Rate limit tier configuration
446
+ */
447
+ interface RateLimitTier {
448
+ /** Window duration in ms */
449
+ windowMs: number;
450
+ /** Max requests in window */
451
+ maxRequests: number;
452
+ /** Error message */
453
+ message: string;
454
+ /** Skip successful requests */
455
+ skipSuccessfulRequests?: boolean;
456
+ /** Skip failed requests */
457
+ skipFailedRequests?: boolean;
458
+ }
459
+ /**
460
+ * Rate limiting configuration
461
+ */
462
+ interface RateLimitConfig {
463
+ /** Enable rate limiting */
464
+ enabled: boolean;
465
+ /** Standard tier */
466
+ standard: RateLimitTier;
467
+ /** Strict tier (auth endpoints) */
468
+ strict: RateLimitTier;
469
+ /** DDoS protection tier */
470
+ ddos: RateLimitTier;
471
+ /** Custom tiers */
472
+ custom?: Record<string, RateLimitTier>;
473
+ }
474
+ /**
475
+ * Complete application configuration
476
+ */
477
+ interface AppConfig {
478
+ server: ServerConfig;
479
+ database: DatabaseConfig;
480
+ auth: AuthConfig;
481
+ logging: LoggingConfig;
482
+ cors: CorsOriginsConfig;
483
+ rateLimit: RateLimitConfig;
484
+ /** Custom configuration */
485
+ custom?: Record<string, unknown>;
486
+ }
487
+ /**
488
+ * Default server configuration
489
+ */
490
+ declare const DEFAULT_SERVER_CONFIG: ServerConfig;
491
+ /**
492
+ * Default database configuration
493
+ */
494
+ declare const DEFAULT_DATABASE_CONFIG: DatabaseConfig;
495
+ /**
496
+ * Default auth configuration
497
+ */
498
+ declare const DEFAULT_AUTH_CONFIG: AuthConfig;
499
+ /**
500
+ * Default logging configuration
501
+ */
502
+ declare const DEFAULT_LOGGING_CONFIG: LoggingConfig;
503
+ /**
504
+ * Default CORS origins configuration
505
+ */
506
+ declare const DEFAULT_CORS_ORIGINS: CorsOriginsConfig;
507
+ /**
508
+ * Default rate limit configuration
509
+ */
510
+ declare const DEFAULT_RATE_LIMIT_CONFIG: RateLimitConfig;
511
+ /**
512
+ * Configuration builder for creating project-specific configs
513
+ */
514
+ declare class ConfigBuilder {
515
+ private config;
516
+ constructor();
517
+ /**
518
+ * Set server configuration
519
+ */
520
+ setServer(config: Partial<ServerConfig>): this;
521
+ /**
522
+ * Set database configuration
523
+ */
524
+ setDatabase(config: Partial<DatabaseConfig>): this;
525
+ /**
526
+ * Set auth configuration
527
+ */
528
+ setAuth(config: Partial<AuthConfig>): this;
529
+ /**
530
+ * Set logging configuration
531
+ */
532
+ setLogging(config: Partial<LoggingConfig>): this;
533
+ /**
534
+ * Set CORS origins
535
+ */
536
+ setCorsOrigins(config: Partial<CorsOriginsConfig>): this;
537
+ /**
538
+ * Add CORS production origin
539
+ */
540
+ addProductionOrigin(origin: string): this;
541
+ /**
542
+ * Add CORS development origin
543
+ */
544
+ addDevelopmentOrigin(origin: string): this;
545
+ /**
546
+ * Add CORS pattern
547
+ */
548
+ addCorsPattern(pattern: string): this;
549
+ /**
550
+ * Set rate limit configuration
551
+ */
552
+ setRateLimit(config: Partial<RateLimitConfig>): this;
553
+ /**
554
+ * Add custom rate limit tier
555
+ */
556
+ addRateLimitTier(name: string, tier: RateLimitTier): this;
557
+ /**
558
+ * Set custom configuration
559
+ */
560
+ setCustom(key: string, value: unknown): this;
561
+ /**
562
+ * Load configuration from environment variables
563
+ */
564
+ loadFromEnv(): this;
565
+ /**
566
+ * Validate configuration
567
+ */
568
+ validate(): {
569
+ valid: boolean;
570
+ errors: string[];
571
+ };
572
+ /**
573
+ * Build the final configuration
574
+ */
575
+ build(): AppConfig;
576
+ }
577
+ /**
578
+ * Create a new configuration builder
579
+ */
580
+ declare const createConfig: () => ConfigBuilder;
581
+ /**
582
+ * Create config from partial object
583
+ */
584
+ declare const buildConfig: (partial?: Partial<AppConfig>) => AppConfig;
585
+ /**
586
+ * Check if current environment is production
587
+ */
588
+ declare const isProduction: (config?: ServerConfig) => boolean;
589
+ /**
590
+ * Check if current environment is development
591
+ */
592
+ declare const isDevelopment: (config?: ServerConfig) => boolean;
593
+ /**
594
+ * Check if current environment is test
595
+ */
596
+ declare const isTest: (config?: ServerConfig) => boolean;
597
+ /**
598
+ * Get database options for mongoose connect
599
+ */
600
+ declare const getDatabaseOptions: (config: DatabaseConfig) => Record<string, unknown>;
601
+
602
+ export { type AppConfig, type AuthConfig, ConfigBuilder, type CorsConfig, type CorsOriginsConfig, DEFAULT_AUTH_CONFIG, DEFAULT_CORS_CONFIG, DEFAULT_CORS_ORIGINS, DEFAULT_DATABASE_CONFIG, DEFAULT_LOGGING_CONFIG, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RATE_LIMIT_TIERS, DEFAULT_SERVER_CONFIG, type DatabaseConfig, EXYCONN_CORS_CONFIG, type Environment, type LogLevel, type LoggingConfig, PERMISSIVE_CORS_CONFIG, RATE_LIMIT_CONFIG, type RateLimitConfig, type RateLimitResponse, type RateLimitTier, type RateLimitTierConfig, RateLimiterBuilder, type RateLimiterConfig, STRICT_CORS_CONFIG, type ServerConfig, buildConfig, corsOptions, createApiKeyGenerator, createApiRateLimiter, createBrandCorsOptions, createConfig, createCorsOptions, createDdosRateLimiter, createMultiBrandCorsOptions, createPrefixedKeyGenerator, createRateLimiter, createStandardRateLimiter, createStrictRateLimiter, createUserKeyGenerator, ddosProtectionLimiter, defaultKeyGenerator, getDatabaseOptions, isDevelopment, isProduction, isTest, rateLimiter, standardRateLimiter, strictRateLimiter };