buildersai / app /config /settings.py
Kushal
Fix: Added default for ALLOWED_ORIGINS to prevent crash
34c2ec3
Raw
History Blame Contribute Delete
1.34 kB
from pydantic_settings import BaseSettings
from typing import List, Optional
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
# App Configuration
SECRET_KEY: str
DEBUG: bool = False
PORT: int = 8000
# Database
DATABASE_URL: str = "sqlite:///data/database.db"
# AI Services
GROQ_API_KEY: str
GROQ_MODEL: str = "llama-3.1-8b-instant"
TAVILY_API_KEY: str
# JWT Configuration
ACCESS_TOKEN_EXPIRE_MINUTES: int = 15
REFRESH_TOKEN_EXPIRE_DAYS: int = 7
ALGORITHM: str = "HS256"
# Google OAuth
GOOGLE_CLIENT_ID: Optional[str] = ""
GOOGLE_CLIENT_SECRET: Optional[str] = ""
GOOGLE_REDIRECT_URI: Optional[str] = ""
# CORS
ALLOWED_ORIGINS: str = "*"
@property
def cors_origins(self) -> List[str]:
"""Parse CORS origins from comma-separated string."""
return [origin.strip() for origin in self.ALLOWED_ORIGINS.split(",")]
# Backward compatibility properties (lowercase)
@property
def secret_key(self) -> str:
return self.SECRET_KEY
@property
def algorithm(self) -> str:
return self.ALGORITHM
class Config:
env_file = ".env"
case_sensitive = True
# Global settings instance
settings = Settings()