This repository was archived by the owner on Aug 6, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathspotify-config.ts
More file actions
95 lines (83 loc) · 3.17 KB
/
Copy pathspotify-config.ts
File metadata and controls
95 lines (83 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Spotify API configuration that adapts to dev mode vs production.
*
* Dev mode (SPOTIFY_DEV_MODE=true):
* - Max 5 authenticated users (Spotify's dev mode limit)
* - Conservative API call budget (~50 calls/30s window)
* - Longer poll intervals, reduced background operation frequency
* - Search results capped at 5 (Feb 2026 dev mode limit)
*
* Production (SPOTIFY_DEV_MODE unset or false):
* - No user cap (extended quota mode)
* - Higher API call budget (~300 calls/30s window)
* - Normal poll intervals and background operations
* - Search results up to 10
*/
export function isSpotifyDevMode(): boolean {
return process.env.SPOTIFY_DEV_MODE === 'true';
}
export const spotifyConfig = {
/** Whether Spotify dev mode restrictions are active */
get devMode() {
return isSpotifyDevMode();
},
/** Max authenticated users allowed (Spotify dev mode = 5) */
get maxUsers() {
return isSpotifyDevMode() ? 5 : Infinity;
},
/** Max search results per query (Feb 2026: dev mode max = 10, default = 5) */
get searchLimit() {
return isSpotifyDevMode() ? 5 : 10;
},
/** Poll interval in ms (dev mode uses longer interval to conserve budget) */
get pollIntervalMs() {
if (process.env.POLL_INTERVAL_MS) {
return Number(process.env.POLL_INTERVAL_MS);
}
return isSpotifyDevMode() ? 60_000 : 30_000;
},
/**
* Max Spotify API calls allowed per rolling 30-second window.
* Dev mode: very conservative (Spotify doesn't publish exact numbers,
* but community reports suggest ~100-180 for dev apps; we stay well under).
* Production: higher budget for extended quota apps.
*/
get apiCallBudget() {
return isSpotifyDevMode() ? 50 : 300;
},
/** How often to run saved-tracks auto-like check (in poll cycles) */
get savedCheckEveryNCycles() {
return isSpotifyDevMode() ? 10 : 4;
},
/** How often to run playlist audit (in poll cycles) */
get auditEveryNCycles() {
return isSpotifyDevMode() ? 6 : 2;
},
/** How often to sync liked playlists (in poll cycles) */
get likedSyncEveryNCycles() {
return isSpotifyDevMode() ? 10 : 4;
},
/** How often to run token keepalive sweep (in poll cycles).
* Dev mode: every 60 cycles (= ~60 min at 60s interval) — very conservative
* to avoid hitting undocumented accounts.spotify.com rate limits.
* Production: every 20 cycles (= ~10 min at 30s interval). */
get tokenKeepaliveEveryNCycles() {
return isSpotifyDevMode() ? 60 : 20;
},
/**
* Minimum interval between Spotify description updates for vibe sync.
* Dev mode: 10 minutes (conserve budget). Production: 5 minutes.
*/
get vibeDescSyncMinIntervalMs() {
return isSpotifyDevMode() ? 10 * 60_000 : 5 * 60_000;
},
} as const;
// ─── Budget Tracking (per-circle) ───────────────────────────────────────────
// Global budget tracking has moved to spotify-budget.ts (per-circle tracking).
// These re-exports maintain backward compatibility during migration.
export {
trackCircleApiCall,
getCircleCallsInWindow,
isCircleOverBudget,
waitForCircleBudget,
} from '@/lib/spotify-budget';