40 lines
926 B
Python
40 lines
926 B
Python
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
from typing import List
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application settings loaded from environment variables."""
|
|
|
|
# Database
|
|
DATABASE_URL: str
|
|
|
|
# Security
|
|
SECRET_KEY: str
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
|
REFRESH_TOKEN_EXPIRE_DAYS: int = 7
|
|
|
|
# Registration
|
|
ALLOW_REGISTRATION: bool = False
|
|
|
|
# CORS
|
|
ALLOWED_ORIGINS: str = "http://localhost:8000"
|
|
|
|
# Environment
|
|
ENVIRONMENT: str = "development"
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
case_sensitive=True
|
|
)
|
|
|
|
@property
|
|
def cors_origins(self) -> List[str]:
|
|
"""Parse comma-separated CORS origins into a list."""
|
|
return [origin.strip() for origin in self.ALLOWED_ORIGINS.split(",")]
|
|
|
|
|
|
# Global settings instance
|
|
settings = Settings()
|