-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.js
More file actions
83 lines (73 loc) · 2.05 KB
/
config.js
File metadata and controls
83 lines (73 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// config.js - Application configuration
const { getSupportedCodes } = require('./src/lang-registry');
const config = {
// Server configuration
server: {
port: process.env.PORT || 3000,
env: process.env.NODE_ENV || 'development',
host: process.env.HOST || 'localhost'
},
// Cache configuration
cache: {
htmlMaxAge: 300, // 5 minutes
translationMaxAge: 3600, // 1 hour
assetMaxAge: 2592000, // 30 days
jsMaxAge: 31536000, // 1 year
staleWhileRevalidate: 86400 // 1 day
},
// Security configuration
security: {
rateLimit: {
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100 // requests per window
},
cors: {
origin: process.env.ALLOWED_ORIGINS || false,
credentials: true
}
},
// Translation configuration
// supportedLanguages 由 src/lang-registry.js 统一管理,此处直接派生
i18n: {
defaultLanguage: 'zh-CN',
supportedLanguages: getSupportedCodes(), // 仅含 hasTranslation: true 的语言
fallbackLanguage: 'zh-CN'
},
// Performance configuration
performance: {
compression: {
level: 6,
threshold: 1024
},
lazyLoading: {
rootMargin: '50px',
threshold: 0.1
}
},
// Feature flags
features: {
enableAnalytics: process.env.ENABLE_ANALYTICS === 'true',
enableErrorReporting: process.env.ENABLE_ERROR_REPORTING === 'true',
enableServiceWorker: false, // Future enhancement
enablePWA: false // Future enhancement
},
// External services
services: {
analytics: {
gtag: process.env.GTAG_ID || null
},
errorReporting: {
sentry: process.env.SENTRY_DSN || null
}
}
};
// Environment-specific overrides
if (config.server.env === 'production') {
config.cache.htmlMaxAge = 1800; // 30 minutes in production
config.security.rateLimit.max = 200; // Higher limit for production
}
if (config.server.env === 'development') {
config.features.enableErrorReporting = true;
config.performance.compression.level = 0; // Disable compression for easier debugging
}
module.exports = config;