feat(api): real login + listening wired to the backend contract
Docker Build & Publish / build (push) Has been cancelled
Docker Build & Publish / push (push) Has been cancelled
Docker Build & Publish / Prune old image versions (push) Has been cancelled

Replace the faked ConnectPage login with a real /auth/login -> /auth/me
flow, including loading/error states. Add a backend-contract adapter layer
(api/mappers.ts) translating the backend's snake_case, lean *Out schemas and
{items,total,limit,offset} paging into the UI's camelCase domain types, so
swapping backends only touches the mappers.

- auth: chained login (tokens) + /auth/me (user); refresh on snake_case;
  expiresIn optional (reauth is 401-driven, backend sends no TTL)
- streaming: GET /stream/{id}?token= (token query param for <audio>); SW
  audio cache route + tests follow the path change (token stays cache-stable)
- library/playlists/likes/admin: correct paths (/tracks not /library/tracks),
  page/pageSize<->limit/offset, duration_seconds->durationMs, likes as
  append-only POST /likes event-log, admin is_superuser<->role
- downloads/storage: marked provisional (backend routes still stubs)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Senko-san
2026-06-08 17:12:44 +03:00
parent bcfb36d53e
commit dacb8b9278
18 changed files with 519 additions and 99 deletions
+2 -2
View File
@@ -19,8 +19,8 @@ export const MAX_BYTES = 500 * 1024 * 1024; // 500 MB
export const COVER_CACHE = 'mcma-covers-v1';
export const MAX_COVERS = 600;
// Backend stream route: /api/v1/streaming/tracks/<trackId>?token=...
const STREAM_RE = /\/streaming\/tracks\/([^/?#]+)/;
// Backend stream route: /api/v1/stream/<trackId>?token=...
const STREAM_RE = /\/stream\/([^/?#]+)/;
/** The track (content) id from a stream URL, or null if it isn't one. */
export function trackIdFromUrl(url) {
+1 -1
View File
@@ -2,7 +2,7 @@
* MCMA service worker — Tier 3 offline support: audio blob cache.
*
* It sits between the app and the network for audio-stream requests only
* (`/streaming/tracks/<id>`). The first time a track is streamed it's copied
* (`/stream/<id>`). The first time a track is streamed it's copied
* into the Cache API (keyed by content id, token stripped); afterwards — or
* whenever the backend is unreachable — playback is served straight from the
* cache, so already-heard tracks play with no network at all.