
- Setup project structure and FastAPI application - Create SQLite database with SQLAlchemy - Implement user authentication with JWT - Create task and user models - Add CRUD operations for tasks and users - Configure Alembic for database migrations - Implement API endpoints for task management - Add error handling and validation - Configure CORS middleware - Create health check endpoint - Add comprehensive documentation
32 lines
870 B
Python
32 lines
870 B
Python
from typing import List
|
|
|
|
from pydantic import validator
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Task Management Tool"
|
|
|
|
# CORS Origins
|
|
BACKEND_CORS_ORIGINS: List[str] = ["*"]
|
|
|
|
@validator("BACKEND_CORS_ORIGINS", pre=True)
|
|
def assemble_cors_origins(self, v: str | List[str]) -> List[str] | str:
|
|
if isinstance(v, str) and not v.startswith("["):
|
|
return [i.strip() for i in v.split(",")]
|
|
if isinstance(v, (list, str)):
|
|
return v
|
|
raise ValueError(v)
|
|
|
|
# JWT
|
|
SECRET_KEY: str = "YOUR_SECRET_KEY_HERE" # Change in production
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8 # 8 days
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
env_file = ".env"
|
|
|
|
|
|
settings = Settings() |