276342520f
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 8s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 3m28s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Runtime Images (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
1. 修复密码重置接口路径不一致 Bug (auth.py) - forgot_password 硬编码 localhost → 使用 APP_BASE_URL 配置 2. 删除 8 处死代码(未使用 import/变量) - 清理多个文件中的未使用导入和变量 3. 删除 8 个空文件/空模块 - 删除无内容的 __init__.py 文件 4. 合并 3 对 100% 完全重复的函数 - 提取 check_project_access/get_user_plan/require_project_and_library - 新建 apps/api/app/api/routes/_helpers.py 作为共享模块 - 6 个路由文件改为从 _helpers 导入 5. 对齐 6 个废弃/异常环境变量 - 修复 DATABASE_POOL_RECYLE 拼写错误 → DATABASE_POOL_RECYCLE - 添加 JWT_ALGORITHM/JWT_ACCESS_TOKEN_EXPIRE_MINUTES/JWT_REFRESH_TOKEN_EXPIRE_DAYS 到 Settings - 修复 jwt_service.py hasattr 字段名匹配 - .env.example: CORS_ORIGINS → CORS_ORIGINS_RAW(逗号分隔格式) - .env.example: 启用 APP_ENV - 修复 OSS_ENDPOINT 默认值拼写错误 (aliiyuncs.com → aliyuncs.com) - 添加 COSYVOICE_* 变量来源注释 修改文件: 52 个(新增 1,删除 8,修改 43)
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
"""Shared settings for API and Worker services."""
|
|
|
|
import os
|
|
from typing import Optional
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class SharedSettings(BaseSettings):
|
|
"""Settings shared between API and Worker services."""
|
|
|
|
# Database
|
|
database_url: str = "postgresql+psycopg://postgres:postgres@localhost:5432/xiaoxia_saas"
|
|
database_pool_size: int = 20
|
|
database_max_overflow: int = 40
|
|
database_pool_timeout: int = 30
|
|
database_pool_recycle: int = 3600
|
|
|
|
# Redis
|
|
redis_url: str = "redis://localhost:6379/0"
|
|
|
|
# Celery
|
|
celery_broker_url: str = "redis://localhost:6379/0"
|
|
celery_result_backend: str = "redis://localhost:6379/1"
|
|
|
|
# OSS Aliyun
|
|
oss_endpoint: str = "oss-cn-hangzhou.aliyuncs.com"
|
|
oss_access_key_id: str = ""
|
|
oss_access_key_secret: str = ""
|
|
oss_bucket_name: str = "xiaoxia-autocut"
|
|
|
|
# CosyVoice (阿里云语音合成)
|
|
cosyvoice_api_key: str = ""
|
|
cosyvoice_base_url: str = "https://dashscope.aliyuncs.com/api/v1/services/aigc/text2audio"
|
|
cosyvoice_model: str = "cosyvoice-v1"
|
|
cosyvoice_voice: str = "longxiaochun" # 默认音色
|
|
cosyvoice_sample_rate: int = 22050
|
|
cosyvoice_format: str = "mp3" # 输出格式:mp3/wav/pcm
|
|
|
|
# Environment
|
|
environment: str = "development"
|
|
auto_create_schema: bool = False
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
case_sensitive=False,
|
|
extra="ignore",
|
|
)
|
|
|
|
|
|
_settings: Optional[SharedSettings] = None
|
|
|
|
|
|
def get_shared_settings() -> SharedSettings:
|
|
"""Get shared settings instance (global singleton)."""
|
|
global _settings
|
|
if _settings is None:
|
|
env = os.getenv("APP_ENV", "development")
|
|
env_file = f".env.{env}" if env != "development" else ".env"
|
|
if os.path.exists(env_file):
|
|
_settings = SharedSettings(_env_file=env_file)
|
|
else:
|
|
_settings = SharedSettings()
|
|
return _settings
|