# spotify-last-known Tiny background service that: 1. Polls Spotify `currently-playing` 2. Persists the last known track to a local JSON file 3. Serves it publicly over HTTP (with CORS) ## Setup Create an `.env` (or export env vars) with: - `SPOTIFY_CLIENT_ID` - `SPOTIFY_CLIENT_SECRET` - `SPOTIFY_REFRESH_TOKEN` Optional: - `PORT` (default: `9783`) - `POLL_MS` (default: `8000`) - `STATE_PATH` (default: `./data/last-known.json`) ## Run ```bash npm i npm start ``` Endpoints: - `GET /last-known` -> persisted state JSON, including `isPlaying`, `progressMs`, and `startedAtMs` while active so static clients can animate playback progress - `GET /healthz` -> `{ ok: true }` ## Notes - Intended for a single machine / single instance. - JSON is written atomically using a temp file + rename.