41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
"""
|
||
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"
|
||
|
||
# 微信小程序
|
||
WX_APPID: str = ""
|
||
WX_SECRET: str = ""
|
||
|
||
# Environment
|
||
ENVIRONMENT: str = "development"
|
||
|
||
class Config:
|
||
case_sensitive = True
|
||
env_file = ".env"
|
||
|
||
|
||
shared_settings = SharedSettings()
|