
- Set up project structure and FastAPI app - Create database models and SQLAlchemy connection - Implement Alembic migration scripts - Add CRUD API endpoints for Todo items - Add health check endpoint - Set up validation, error handling, and middleware - Add comprehensive documentation in README.md
22 lines
665 B
Python
22 lines
665 B
Python
from fastapi import HTTPException, status
|
|
|
|
|
|
class TodoNotFoundException(HTTPException):
|
|
def __init__(self, detail: str = "Todo not found"):
|
|
super().__init__(status_code=status.HTTP_404_NOT_FOUND, detail=detail)
|
|
|
|
|
|
class DatabaseError(HTTPException):
|
|
def __init__(self, detail: str = "Database error"):
|
|
super().__init__(
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
detail=detail,
|
|
)
|
|
|
|
|
|
class ValidationError(HTTPException):
|
|
def __init__(self, detail: str = "Validation error"):
|
|
super().__init__(
|
|
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
|
detail=detail,
|
|
) |