api / app /config.py
hanbinsite's picture
fix: add env_file_encoding utf-8 to fix Windows GBK decode error on .env load
6f5981f
Raw History Blame Contribute Delete
1.13 kB
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
DATABASE_URL: str = "sqlite+aiosqlite:///./binv.db"
# 生产数据库 URL 必须通过环境变量注入,不在代码中提供默认值
DATABASE_URL_PROD: str = ""
# JWT 密钥必须通过环境变量注入,生产环境不得使用默认值
SECRET_KEY: str = "dev-only-change-in-production"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 1440
CORS_ORIGINS: str = "http://localhost:3000,http://localhost:5777,http://localhost:5555"
SYNC_CRON_HOUR: int = 1
SYNC_MAX_CONCURRENT: int = 3
SYNC_MAX_PAGES: int = 100
# Redis 配置(缓存层,可选,不配置则降级为无缓存模式)
REDIS_URL: str = "redis://localhost:6379/0"
CACHE_ENABLED: bool = True
# 各类缓存 TTL(秒)
CACHE_TTL_VOD_LIST: int = 300 # 影片列表缓存 5 分钟
CACHE_TTL_VOD_DETAIL: int = 600 # 影片详情缓存 10 分钟
CACHE_TTL_CATEGORY: int = 3600 # 分类树缓存 1 小时
model_config = {"env_file": ".env", "env_file_encoding": "utf-8", "extra": "ignore"}
settings = Settings()