Repository navigation
Move from Spotify to TIDAL, rebuilt for speed, and ready for Vercel - #3
Merged
Merged
Conversation
Replace the Spotify integration with TIDAL's v2 API and rebuild the site for speed, responsiveness and resilience. Server - Fetch all public playlists and their cover art in a few paginated requests (filter[owners.id] + include=coverArt) instead of one request per playlist. - Client-credentials auth by default, with a refresh-token fallback and a one-time PKCE sign-in helper (npm run tidal:login) in case TIDAL requires a user to read playlists. - Retries with backoff for network errors, 429 (Retry-After) and 5xx; a fresh token on 401; typed errors that carry TIDAL's own details. - Only public playlists are ever exposed, whichever credentials are used. - Catalogue served from memory with stale-while-revalidate, a last-known-good snapshot on disk, and back-off while TIDAL is failing. - Manifest + delta API with ETags, so browsers fetch only what changed. - Security headers with a per-request CSP nonce; CSP violation and browser error intake; structured logs with request ids; optional Sentry; health endpoint; graceful shutdown. - Content-hashed asset URLs served immutable, without a build step. Browser - Renders instantly from a localStorage copy, then syncs: usually a bodiless 304, otherwise only new or changed playlists are downloaded. - Artwork-first responsive grid: srcset/sizes, lazy loading, first-row priority hints and palette-colour placeholders. - Live search over titles, tags and descriptions; artist/genre tags parsed from titles; sorting; shareable URLs for every view. - Native modal dialog with TIDAL's embedded player, Open in TIDAL and Copy link; Back button and Esc close it; light dismiss. - Clear error, offline, empty and retry states; errors reported to the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YXBoVxYxPpig7Tkb6fDbc6
- 97 tests on Node's built-in runner: title/tag parsing, artwork selection, privacy filtering, token handling, retries, pagination, catalogue refresh/back-off/snapshots, the HTTP API (ETags, 304s, errors, security headers, caching), report intake, configuration, and the browser's search, formatting and delta-sync logic. - GitHub Actions runs a syntax check and the tests on Node 22 and 24 for every pull request and push to main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YXBoVxYxPpig7Tkb6fDbc6
Setup, the TIDAL sign-in fallback, deployment on Render, how caching and syncing work, error handling and reporting, and the project layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YXBoVxYxPpig7Tkb6fDbc6
With client credentials, TIDAL answers a filter[owners.id] query with an empty list rather than an error, so the site showed "0 playlists" with the loading skeletons stuck on screen. - Treat an empty result under client credentials as a sign-in problem and say how to fix it (npm run tidal:login -- --save). - Ignore empty snapshots on disk so one can't outlive the fix. - Always replace the loading skeletons on the first render, including empty results and failed loads, and show a message when there are no playlists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Pause 400ms between pages of TIDAL results. Back-to-back pages were hitting TIDAL's rate limit (429), which the retries absorbed but which slowed a cold start to ~14s. - Log retries as one line instead of a full stack trace. - Don't log /.well-known/ probes (Chrome DevTools asks for one on every load). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vercel runs Express apps as a function rather than a long-running server. - app.js exports the Express app; it only listens on a port off Vercel. Start-up is split into createSite() and serve() in src/site.js. - vercel.json maps versioned /static/<hash>/ URLs onto public/ (served by Vercel's CDN, cached for a year), bundles views/ and public/ into the function, and allows 60s for a cold fetch from TIDAL. - Playlist API responses carry Vercel-CDN-Cache-Control (10 min, with stale-while-revalidate), so visitors rarely wait for TIDAL. Browsers still revalidate with ETags. Errors and the page are never CDN-cached. - Background refreshes and Sentry flushes go through waitUntil, so they finish after the response is sent. - The playlist snapshot is written to the temp directory on Vercel. - SITE_URL, release and environment default from Vercel's system variables. - README deployment guide rewritten for Vercel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces Spotify with TIDAL and rebuilds the site to be faster, responsive on every screen size, and resilient. It is ready to deploy on Vercel.
npm run tidal:login -- --save. Private and unlisted playlists are never shown.304back. When something has changed, only new or edited playlists are downloaded.SENTRY_DSN)./healthzreports health, and the server keeps serving the last good copy if TIDAL is down.app.jsexports the Express app as a Vercel Function.vercel.jsonhandles static asset rewrites, caching and function settings. Background work runs throughwaitUntil.Deploying
TIDAL_CLIENT_ID,TIDAL_CLIENT_SECRET,TIDAL_USER_ID,TIDAL_REFRESH_TOKEN, and optionallyTIDAL_PROFILE_URL,SENTRY_DSN, andSITE_URL(only for a custom domain)./healthzon the preview deployment.Testing
npm test: 103 tests covering the TIDAL client, catalogue, HTTP API, configuration, error reporting and the browser's sync/search logic.npm run checksyntax-checks all JS. Both run in CI on Node 22 and 24.npm run dev:mock).🤖 Generated with Claude Code