Replace mock API layer with real backend integration #1

Closed
opened 2026-03-21 21:13:22 +00:00 by Mark · 21 comments
Owner

Description

Replace the mock API layer in src/lib/api.ts with real HTTP calls to a backend server.

Current State

  • All API functions use mock data with simulated delays
  • Functions return hardcoded mock data from mockData.ts
  • No actual network requests are made

Required Changes

  1. Create API client with proper error handling
  2. Replace mock data returns with fetch/axios calls
  3. Add authentication headers (JWT tokens)
  4. Implement proper error handling with { data, error } tuples
  5. Add request/response type definitions
  6. Handle network errors gracefully

Files Affected

  • src/lib/api.ts (entire file)
  • May need: src/lib/client.ts (new API client)

Acceptance Criteria

  • All API functions call real backend endpoints
  • Authentication is properly handled
  • Errors return as { data, error } tuples
  • Loading states work correctly
## Description Replace the mock API layer in `src/lib/api.ts` with real HTTP calls to a backend server. ## Current State - All API functions use mock data with simulated delays - Functions return hardcoded mock data from `mockData.ts` - No actual network requests are made ## Required Changes 1. Create API client with proper error handling 2. Replace mock data returns with `fetch`/`axios` calls 3. Add authentication headers (JWT tokens) 4. Implement proper error handling with `{ data, error }` tuples 5. Add request/response type definitions 6. Handle network errors gracefully ## Files Affected - `src/lib/api.ts` (entire file) - May need: `src/lib/client.ts` (new API client) ## Acceptance Criteria - [ ] All API functions call real backend endpoints - [ ] Authentication is properly handled - [ ] Errors return as `{ data, error }` tuples - [ ] Loading states work correctly
Author
Owner

Feature Triage Assessment

Scope: small
Risk: low
Spec Alignment: misaligned
Summary: Issue requests replacing a mock API layer with real backend calls, but this work was already completed — api.ts already makes real HTTP requests via client.ts and does not use mock data.
Recommendation: Close as already done. The real API integration is fully in place: client.ts handles JWT auth, fetch, interceptors, and error throwing (per spec), while api.ts provides typed domain APIs (volumesApi, targetsApi, etc.) with context-aware error wrapping. The only cleanup opportunity is removing the dead mockData.ts + its test file, since nothing imports them.
Rationale: SCOPE=small: Issue's premise is already implemented — api.ts (459 lines) calls real endpoints through client.ts, not mock data. RISK=low: existing code is well-structured, tested (client.test.ts has 245 lines of vitest coverage), and stores already use real APIs. SPEC=misaligned: (1) Issue asks for { data, error } tuples, but AGENTS.md explicitly says 'API functions throw errors on failure (not { data, error } tuples)' — current code correctly throws. (2) Issue says 'May need: src/lib/client.ts (new API client)' — it already exists with interceptor pipeline, auth, and tests. (3) Issue describes mock delays/hardcoded returns, but api.ts has zero imports from mockData.ts and never simulates delays. The issue appears to have been filed against an older revision and never closed.

Labeled blocked:needs-decision — unblock on Forgejo to dispatch to the fixer pipeline.

## Feature Triage Assessment **Scope:** small **Risk:** low **Spec Alignment:** misaligned **Summary:** Issue requests replacing a mock API layer with real backend calls, but this work was already completed — `api.ts` already makes real HTTP requests via `client.ts` and does not use mock data. **Recommendation:** Close as already done. The real API integration is fully in place: `client.ts` handles JWT auth, fetch, interceptors, and error throwing (per spec), while `api.ts` provides typed domain APIs (`volumesApi`, `targetsApi`, etc.) with context-aware error wrapping. The only cleanup opportunity is removing the dead `mockData.ts` + its test file, since nothing imports them. **Rationale:** SCOPE=small: Issue's premise is already implemented — `api.ts` (459 lines) calls real endpoints through `client.ts`, not mock data. RISK=low: existing code is well-structured, tested (client.test.ts has 245 lines of vitest coverage), and stores already use real APIs. SPEC=misaligned: (1) Issue asks for `{ data, error }` tuples, but AGENTS.md explicitly says 'API functions throw errors on failure (not { data, error } tuples)' — current code correctly throws. (2) Issue says 'May need: src/lib/client.ts (new API client)' — it already exists with interceptor pipeline, auth, and tests. (3) Issue describes mock delays/hardcoded returns, but api.ts has zero imports from mockData.ts and never simulates delays. The issue appears to have been filed against an older revision and never closed. Labeled `blocked:needs-decision` — unblock on Forgejo to dispatch to the fixer pipeline.
Author
Owner

Note: #2 (Docker daemon integration for volume discovery) is a sub-task within this issue's scope — closing as duplicate.

Note: #2 (Docker daemon integration for volume discovery) is a sub-task within this issue's scope — closing as duplicate.
Author
Owner

🤖 Claimed by gsd-issue-fixer-docker_backup-1 — starting work

🤖 Claimed by `gsd-issue-fixer-docker_backup-1` — starting work
Author
Owner

🤖 Claimed by gsd-issue-fixer-docker_backup-1 — starting work

🤖 Claimed by `gsd-issue-fixer-docker_backup-1` — starting work
Author
Owner

🤖 Claimed by gsd-issue-fixer-docker_backup-1 — starting work

🤖 Claimed by `gsd-issue-fixer-docker_backup-1` — starting work
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — claimed — starting pipeline

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — claimed — starting pipeline
Author
Owner

🤖 Claimed by gsd-issue-fixer-docker_backup-1 — starting work

🤖 Claimed by `gsd-issue-fixer-docker_backup-1` — starting work
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — claimed — starting pipeline

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — claimed — starting pipeline
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — claimed — starting pipeline

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — claimed — starting pipeline
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — claimed — starting pipeline

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — claimed — starting pipeline
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — research

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — research
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — research

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — research
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — research

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — research
Author
Owner

GSD pipeline blocked at RESEARCH: prerequisite gate (fetch) not passed.
Pipeline state needs reset. Check if another run is in progress.

GSD pipeline blocked at RESEARCH: prerequisite gate (fetch) not passed. Pipeline state needs reset. Check if another run is in progress.
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — plan

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — plan
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — plan

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — plan
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — implement attempt 1

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — implement attempt 1
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — implement attempt 1

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — implement attempt 1
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — plan

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — plan
Author
Owner

🤖 [gsd-issue-fixer-docker_backup-1] still working — implement attempt 1

🤖 [`gsd-issue-fixer-docker_backup-1`] still working — implement attempt 1
Author
Owner

Fixed in commit. Closing.

Fixed in commit. Closing.
Mark closed this issue 2026-05-27 21:29:32 +00:00
Sign in to join this conversation.
No description provided.