Skip to content

feat(frontend): migrate REST/audio/SW to /api/v1#41

Merged
revtex merged 2 commits intodevfrom
feat/frontend-v1-migration
Apr 27, 2026
Merged

feat(frontend): migrate REST/audio/SW to /api/v1#41
revtex merged 2 commits intodevfrom
feat/frontend-v1-migration

Conversation

@revtex
Copy link
Copy Markdown
Owner

@revtex revtex commented Apr 27, 2026

Why

The legacy-usage report on production is showing the embedded frontend itself as the top consumer of /api/* deprecation traffic:

Method Path API key Count
POST /api/auth/refresh (unauthenticated) 17
GET /api/calls/:id/audio u:1 7
PUT /api/auth/tg-selection u:1 18
GET /api/calls u:1 1
GET /api/auth/tg-selection u:1 8
GET /api/bookmarks u:1 9
GET /api/bookmarks/calls u:1 9
GET /api/setup/status (unauthenticated) 9
GET /api/ws (unauthenticated) 1
GET /api/health (unauthenticated) 87

Every one of those is the embedded SPA. The native /api/v1/* surface has shipped and the WS clients already use /api/v1/ws/{listener,admin}, but the REST + audio paths were left on the legacy URLs.

What

  • RTK Query baseUrl/api/v1
  • tg-selection slice → /listener/tg-selection (matches the v1 rename)
  • /admin/radioreference/preview/csv/admin/radioreference/preview (v1 dropped the /csv suffix)
  • /v1/admin/legacy-usage (relative-to-/api hack) → /admin/legacy-usage
  • Raw fetch() in main.tsx audio-recovery and ToolsPanel Swagger session bootstrap → /api/v1/...
  • Audio download URLs in player.ts, BookmarksPanel, SearchPanel/api/v1/calls/:id/audio
  • Service worker passthrough regex accepts both /api/v1/{calls,shared} and the legacy variants (so an old SW cached on a client doesn't break audio during the transition)
  • Vite dev proxy forwards /api/v1/ws WebSocket upgrades

Legacy /api/* routes remain available with deprecation headers — this only changes what the embedded frontend asks for.

Validation

  • npx tsc --noEmit — clean
  • pnpm test — 201/201 passing
  • pnpm build — succeeds
  • go vet ./... && go build ./... — clean
  • Pre-existing lint error in downloadFilename.ts is on dev and unrelated to this PR

Out of scope

External callers (TR uploaders, SDRTrunk shim, third-party clients) still hit /api/* and will continue to surface in the legacy-usage report — that's the whole point of that report. After this PR lands the only entries should be from real third-party clients.

revtex added 2 commits April 27, 2026 02:35
The frontend has been carrying legacy /api/* deprecation traffic since
the native v1 surface landed. Move every client-side caller over to v1
so production logs stop showing self-inflicted hits in the legacy-usage
report:

- RTK Query base URL flips to /api/v1
- /api/v1/listener/tg-selection (was /api/auth/tg-selection)
- /api/v1/admin/radioreference/preview (was /admin/radioreference/preview/csv)
- /api/v1/admin/legacy-usage (was /v1/admin/legacy-usage relative to /api)
- raw fetch() in main.tsx auth-recovery and ToolsPanel Swagger session
- audio download URLs in player.ts, BookmarksPanel, SearchPanel
- service worker passthrough regex accepts both /api/v1/{calls,shared}
  and the legacy variants during the transition window
- vite dev proxy forwards /api/v1/ws WebSocket upgrades

Legacy /api/* routes remain available with deprecation headers for
external consumers; this only moves the embedded frontend.

All 201 vitest specs pass. tsc clean. Backend unchanged.
The directive was on the const declaration; ESLint reports it unused
because the actual regex literal sits on the next line. Move the
comment onto the .replace() call that owns the control-class regex.
@revtex revtex merged commit 3a45913 into dev Apr 27, 2026
7 checks passed
@revtex revtex deleted the feat/frontend-v1-migration branch April 27, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant