import api from './api'; import type { Genre, Track } from '../types'; export interface GetGenreTracksParams { limit?: number; offset?: number; } export const genreService = { // GET /api/genres — all genres with a track_count, ordered by popularity. async listGenres(): Promise { const res = await api.get('/genres'); return res.data; }, // GET /api/genres/:id — a single genre (with track_count), or null if missing. async getGenre(id: string): Promise { try { const res = await api.get(`/genres/${id}`); return res.data; } catch { return null; } }, // GET /api/genres/:id/tracks — LIBRARY tracks in this genre, by weight DESC. async getGenreTracks(id: string, params?: GetGenreTracksParams): Promise { const res = await api.get(`/genres/${id}/tracks`, { params }); return res.data; }, };