A tiny spotify microservice

simo df9872644d bar пре 3 дана
data eff872ac60 spotify пре 2 недеља
src df9872644d bar пре 3 дана
.gitignore eff872ac60 spotify пре 2 недеља
Dockerfile eff872ac60 spotify пре 2 недеља
README.md df9872644d bar пре 3 дана
docker-compose.yml eff872ac60 spotify пре 2 недеља
package-lock.json eff872ac60 spotify пре 2 недеља
package.json eff872ac60 spotify пре 2 недеља

README.md

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

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.