Files
sse-server/config/index.js
2025-07-05 16:58:28 +08:00

30 lines
864 B
JavaScript

/**
* @file 应用配置文件
* @author Yk <yk_9001@icloud.com>
* @createdAt 2025-07-01
* @lastModifiedAt 2025-07-01
* @description 包含服务器、SSE和限流配置
*/
module.exports = {
server: {
port: process.env.PORT || 3080,
env: process.env.NODE_ENV || 'development'
},
sse: {
heartbeatInterval: 30000, // 30秒
allowedOrigins: '*', //process.env.ALLOWED_ORIGINS?.split(',') || ['http://localhost:3001']
},
rateLimit: {
windowMs: 15 * 60 * 1000, // 15分钟
max: 10000 // 每个IP限制10000个请求
},
redis: {
url: process.env.REDIS_URL || 'redis://localhost:6379',
database: process.env.REDIS_DB || 1, // 默认使用DB1
socket: {
reconnectStrategy: (retries) => Math.min(retries * 100, 5000)
},
ttl: 86400
}
};