Files
weibo_signin/backend/shared/config.py
2026-03-17 13:01:51 +08:00

45 lines
1.3 KiB
Python
Raw Permalink 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"
# 微信小程序
WX_APPID: str = ""
WX_SECRET: str = ""
# Environment
ENVIRONMENT: str = "development"
class Config:
case_sensitive = True
# Docker 环境下不读 .env 文件,靠 docker-compose environment 注入
# 本地开发时 .env 文件仍然生效
env_file = ".env"
env_file_encoding = "utf-8"
extra = "ignore"
shared_settings = SharedSettings()