Add API and worker: accounts, follows, now-playing, cross-service links

- Fastify API with cookie (web) and bearer (mobile) sessions, follows,
  pinned friends, featured songs, account deletion, Redis-backed rate limits
- Providers: Spotify (OAuth), Last.fm, ListenBrainz, Plex (PIN flow and
  server discovery), Jellyfin (token auth, revoked on disconnect)
- Worker polls on an adaptive schedule in a Redis sorted set, so polling
  scales horizontally and API usage tracks whether anyone is watching
- Track resolver links songs across services via ISRC (Deezer, Spotify),
  iTunes search and song.link
- Realtime updates over WebSocket fan out through Redis pub/sub
- User-supplied server URLs are restricted to public addresses, checked
  both up front and at connect time to defeat DNS rebinding

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
This commit is contained in:
2026-10-03 09:59:02 -04:00
co-authored by Claude Opus 5.5
parent 57c1733bab
commit 6791b62d87
45 changed files with 4990 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
{
"name": "@musicshare/api",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "concurrently -n api,worker -c blue,magenta \"tsx watch src/server.ts\" \"tsx watch src/worker.ts\"",
"build": "tsup src/server.ts src/worker.ts --format esm --target node22 --noExternal @musicshare/shared",
"start": "node dist/server.js",
"start:worker": "node dist/worker.js",
"typecheck": "tsc -p .",
"db:generate": "drizzle-kit generate",
"db:migrate": "tsx src/db/migrate.ts"
},
"dependencies": {
"@fastify/cookie": "^11.1.2",
"@fastify/cors": "^11.3.0",
"@fastify/rate-limit": "^11.2.0",
"@fastify/websocket": "^11.3.2",
"@node-rs/argon2": "^2.2.1",
"bullmq": "^6.3.11",
"dotenv": "^18.0.5",
"drizzle-orm": "^0.45.3",
"fastify": "^5.12.5",
"ioredis": "^6.0.0",
"postgres": "^3.4.9",
"undici": "^6.29.0",
"zod": "^4.6.5",
"@musicshare/shared": "*"
},
"devDependencies": {
"@types/node": "^26.6.4",
"@types/ws": "^8.18.2",
"concurrently": "^10.0.5",
"drizzle-kit": "^0.31.11",
"tsup": "^8.5.1",
"tsx": "^4.23.15",
"typescript": "~6.0.3"
}
}