feat: project skeleton

- infra (k8s, kind, helm, docker) backbone is implemented
- security: implementation + unit tests are done
This commit is contained in:
2025-11-21 12:00:00 -05:00
commit fcce32bca9
46 changed files with 3468 additions and 0 deletions

59
app/core/exceptions.py Normal file
View File

@@ -0,0 +1,59 @@
"""Custom HTTP exceptions for the API."""
from fastapi import HTTPException, status
class NotFoundError(HTTPException):
"""Resource not found."""
def __init__(self, detail: str = "Resource not found") -> None:
super().__init__(status_code=status.HTTP_404_NOT_FOUND, detail=detail)
class ConflictError(HTTPException):
"""Conflict with current state (e.g., version mismatch)."""
def __init__(self, detail: str = "Conflict with current state") -> None:
super().__init__(status_code=status.HTTP_409_CONFLICT, detail=detail)
class UnauthorizedError(HTTPException):
"""Authentication required or failed."""
def __init__(self, detail: str = "Not authenticated") -> None:
super().__init__(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=detail,
headers={"WWW-Authenticate": "Bearer"},
)
class ForbiddenError(HTTPException):
"""Insufficient permissions."""
def __init__(self, detail: str = "Insufficient permissions") -> None:
super().__init__(status_code=status.HTTP_403_FORBIDDEN, detail=detail)
class BadRequestError(HTTPException):
"""Invalid request data."""
def __init__(self, detail: str = "Invalid request") -> None:
super().__init__(status_code=status.HTTP_400_BAD_REQUEST, detail=detail)
class ValidationError(HTTPException):
"""Validation failed."""
def __init__(self, detail: str = "Validation failed") -> None:
super().__init__(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=detail)
__all__ = [
"BadRequestError",
"ConflictError",
"ForbiddenError",
"NotFoundError",
"UnauthorizedError",
"ValidationError",
]