mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
first commit
This commit is contained in:
90
config/config.example.js
Normal file
90
config/config.example.js
Normal file
@@ -0,0 +1,90 @@
|
||||
const path = require('path');
|
||||
require('dotenv').config();
|
||||
|
||||
const config = {
|
||||
// 🌐 服务器配置
|
||||
server: {
|
||||
port: parseInt(process.env.PORT) || 3000,
|
||||
host: process.env.HOST || '0.0.0.0',
|
||||
nodeEnv: process.env.NODE_ENV || 'development',
|
||||
trustProxy: process.env.TRUST_PROXY === 'true'
|
||||
},
|
||||
|
||||
// 🔐 安全配置
|
||||
security: {
|
||||
jwtSecret: process.env.JWT_SECRET || 'CHANGE-THIS-JWT-SECRET-IN-PRODUCTION',
|
||||
adminSessionTimeout: parseInt(process.env.ADMIN_SESSION_TIMEOUT) || 86400000, // 24小时
|
||||
apiKeyPrefix: process.env.API_KEY_PREFIX || 'cr_',
|
||||
encryptionKey: process.env.ENCRYPTION_KEY || 'CHANGE-THIS-32-CHARACTER-KEY-NOW'
|
||||
},
|
||||
|
||||
// 📊 Redis配置
|
||||
redis: {
|
||||
host: process.env.REDIS_HOST || '127.0.0.1',
|
||||
port: parseInt(process.env.REDIS_PORT) || 6379,
|
||||
password: process.env.REDIS_PASSWORD || '',
|
||||
db: parseInt(process.env.REDIS_DB) || 0,
|
||||
connectTimeout: 10000,
|
||||
commandTimeout: 5000,
|
||||
retryDelayOnFailover: 100,
|
||||
maxRetriesPerRequest: 3,
|
||||
lazyConnect: true
|
||||
},
|
||||
|
||||
// 🎯 Claude API配置
|
||||
claude: {
|
||||
apiUrl: process.env.CLAUDE_API_URL || 'https://api.anthropic.com/v1/messages',
|
||||
apiVersion: process.env.CLAUDE_API_VERSION || '2023-06-01',
|
||||
betaHeader: process.env.CLAUDE_BETA_HEADER || 'claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14'
|
||||
},
|
||||
|
||||
// 🌐 代理配置
|
||||
proxy: {
|
||||
timeout: parseInt(process.env.DEFAULT_PROXY_TIMEOUT) || 30000,
|
||||
maxRetries: parseInt(process.env.MAX_PROXY_RETRIES) || 3
|
||||
},
|
||||
|
||||
// 📈 使用限制
|
||||
limits: {
|
||||
defaultTokenLimit: parseInt(process.env.DEFAULT_TOKEN_LIMIT) || 1000000,
|
||||
defaultRequestLimit: parseInt(process.env.DEFAULT_REQUEST_LIMIT) || 1000
|
||||
},
|
||||
|
||||
// 🚦 速率限制
|
||||
rateLimit: {
|
||||
windowMs: parseInt(process.env.RATE_LIMIT_WINDOW) || 60000,
|
||||
maxRequests: parseInt(process.env.RATE_LIMIT_MAX_REQUESTS) || 100
|
||||
},
|
||||
|
||||
// 📝 日志配置
|
||||
logging: {
|
||||
level: process.env.LOG_LEVEL || 'info',
|
||||
dirname: path.join(__dirname, '..', 'logs'),
|
||||
maxSize: process.env.LOG_MAX_SIZE || '10m',
|
||||
maxFiles: parseInt(process.env.LOG_MAX_FILES) || 5
|
||||
},
|
||||
|
||||
// 🔧 系统配置
|
||||
system: {
|
||||
cleanupInterval: parseInt(process.env.CLEANUP_INTERVAL) || 3600000, // 1小时
|
||||
tokenUsageRetention: parseInt(process.env.TOKEN_USAGE_RETENTION) || 2592000000, // 30天
|
||||
healthCheckInterval: parseInt(process.env.HEALTH_CHECK_INTERVAL) || 60000 // 1分钟
|
||||
},
|
||||
|
||||
// 🎨 Web界面配置
|
||||
web: {
|
||||
title: process.env.WEB_TITLE || 'Claude Relay Service',
|
||||
description: process.env.WEB_DESCRIPTION || 'Multi-account Claude API relay service with beautiful management interface',
|
||||
logoUrl: process.env.WEB_LOGO_URL || '/assets/logo.png',
|
||||
enableCors: process.env.ENABLE_CORS === 'true',
|
||||
sessionSecret: process.env.WEB_SESSION_SECRET || 'CHANGE-THIS-SESSION-SECRET'
|
||||
},
|
||||
|
||||
// 🛠️ 开发配置
|
||||
development: {
|
||||
debug: process.env.DEBUG === 'true',
|
||||
hotReload: process.env.HOT_RELOAD === 'true'
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
Reference in New Issue
Block a user