from pydantic_settings import BaseSettings from pydantic import field_validator from typing import List import os class Settings(BaseSettings): # App APP_NAME: str = "Stock Platform API" DEBUG: bool = False API_V1_PREFIX: str = "/api/v1" # Database DATABASE_URL: str = "postgresql+asyncpg://stock:stockpass@localhost:5432/stockdb" # Redis REDIS_URL: str = "redis://localhost:6379/0" CELERY_BROKER_URL: str = "redis://localhost:6379/1" # Auth SECRET_KEY: str = "change-me-in-production" ALGORITHM: str = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 REFRESH_TOKEN_EXPIRE_DAYS: int = 7 # CORS ALLOWED_ORIGINS: str = "http://localhost:3000,http://localhost:5173" @property def cors_origins(self) -> List[str]: return [o.strip() for o in self.ALLOWED_ORIGINS.split(",")] # Tushare (optional) TUSHARE_TOKEN: str = "" class Config: env_file = ".env" extra = "ignore" settings = Settings()