Skip to content

feat(backend): add standardized API response envelope #46

Description

@GRACENOBLE

Problem

API responses have no consistent shape. Some handlers return raw structs, others return ad-hoc maps. Clients (web, mobile) have to handle each endpoint differently.

Proposed shape

// success
{ "data": { ... } }

// error
{ "error": { "code": "NOT_FOUND", "message": "user not found" } }

Acceptance criteria

  • Define Response[T]" and ErrorResponsetypes in a shared package (e.g.internal/transport/handlers/response.go`)
  • Add helpers: JSON(c, data)" and JSONError(c, status, code, message)`
  • Update all existing handlers to use the helpers
  • Document the envelope format in backend/docs/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: backendGo REST APIpriority: criticalMust fix immediately — production incident or blockertype: featureNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions