response.py 557 B

123456789101112131415
  1. """Common response helpers for the project.
  2. Provides success_response and error_response helpers to standardize API responses.
  3. """
  4. from typing import Any, Dict
  5. def success_response(data: Any = None, msg: str = "success", code: int = 200) -> Dict[str, Any]:
  6. """Return a standardized success response."""
  7. return {"code": code, "msg": msg, "data": data}
  8. def error_response(msg: str = "error", code: int = 500, data: Any = None) -> Dict[str, Any]:
  9. """Return a standardized error response."""
  10. return {"code": code, "msg": msg, "data": data}