Files
weibo_signin/backend/shared/config.py
2026-03-09 16:10:29 +08:00

37 lines
1022 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Shared configuration for all Weibo-HotSign backend services.
Loads settings from environment variables using pydantic-settings.
"""
from pydantic_settings import BaseSettings
from typing import Optional
class SharedSettings(BaseSettings):
"""Shared settings across all backend services."""
# Database (默认使用 SQLite生产环境可配置为 MySQL)
DATABASE_URL: str = "sqlite+aiosqlite:///../weibo_hotsign.db"
#mysql+aiomysql://root:password@localhost/weibo_hotsign
# Redis (可选,本地开发可以不使用)
REDIS_URL: Optional[str] = None
USE_REDIS: bool = False # 是否启用 Redis
# JWT
JWT_SECRET_KEY: str = "change-me-in-production"
JWT_ALGORITHM: str = "HS256"
JWT_EXPIRATION_HOURS: int = 24
# Cookie encryption
COOKIE_ENCRYPTION_KEY: str = "change-me-in-production"
# Environment
ENVIRONMENT: str = "development"
class Config:
case_sensitive = True
env_file = ".env"
shared_settings = SharedSettings()