
Create a full-featured task management API with the following components: - RESTful CRUD operations for tasks - Task status and priority management - SQLite database with SQLAlchemy ORM - Alembic migrations - Health check endpoint - Comprehensive API documentation
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
"""
|
|
Configuration settings for the Task Manager API.
|
|
"""
|
|
from typing import List, Union
|
|
|
|
from pydantic import AnyHttpUrl, field_validator
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""
|
|
Application settings. Loads from environment variables.
|
|
"""
|
|
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", case_sensitive=True)
|
|
|
|
API_V1_STR: str = "/api/v1"
|
|
API_VERSION: str = "0.1.0"
|
|
PROJECT_NAME: str = "Task Manager API"
|
|
|
|
# CORS settings
|
|
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
|
|
@field_validator("BACKEND_CORS_ORIGINS", mode="before")
|
|
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
|
|
"""
|
|
Parse CORS origins from environment variable.
|
|
"""
|
|
if isinstance(v, str) and not v.startswith("["):
|
|
return [i.strip() for i in v.split(",")]
|
|
elif isinstance(v, (list, str)):
|
|
return v
|
|
raise ValueError(v)
|
|
|
|
|
|
settings = Settings() |