2026-03-23 12:34:27 +03:00
|
|
|
import axios from 'axios'
|
2026-03-19 17:31:09 +03:00
|
|
|
|
2026-03-23 12:34:27 +03:00
|
|
|
const API_BASE = import.meta.env.VITE_API_BASE_URL ?? ''
|
|
|
|
|
export const API_ROOT = `${API_BASE}/api`
|
2026-03-19 17:31:09 +03:00
|
|
|
|
2026-03-23 12:34:27 +03:00
|
|
|
const apiKey = import.meta.env.VITE_API_KEY
|
|
|
|
|
|
|
|
|
|
export const furumiApi = axios.create({
|
|
|
|
|
baseURL: API_ROOT,
|
|
|
|
|
headers: apiKey ? { 'x-api-key': apiKey } : {},
|
|
|
|
|
})
|
2026-03-19 17:31:09 +03:00
|
|
|
|
2026-03-23 12:45:24 +03:00
|
|
|
export async function getArtists() {
|
|
|
|
|
const res = await furumiApi.get('/artists').catch(() => null)
|
|
|
|
|
return res?.data ?? null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getArtistAlbums(artistSlug: string) {
|
|
|
|
|
const res = await furumiApi.get(`/artists/${artistSlug}/albums`).catch(() => null)
|
|
|
|
|
return res?.data ?? null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getAlbumTracks(albumSlug: string) {
|
|
|
|
|
const res = await furumiApi.get(`/albums/${albumSlug}`).catch(() => null)
|
|
|
|
|
return res?.data ?? null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getArtistTracks(artistSlug: string) {
|
|
|
|
|
const res = await furumiApi.get(`/artists/${artistSlug}/tracks`).catch(() => null)
|
|
|
|
|
return res?.data ?? null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function searchTracks(query: string) {
|
|
|
|
|
const res = await furumiApi.get(`/search?q=${encodeURIComponent(query)}`).catch(() => null)
|
|
|
|
|
return res?.data ?? null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getTrackInfo(trackSlug: string) {
|
|
|
|
|
const res = await furumiApi.get(`/tracks/${trackSlug}`).catch(() => null)
|
|
|
|
|
return res?.data ?? null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function preloadStream(trackSlug: string) {
|
|
|
|
|
await furumiApi.get(`/stream/${trackSlug}`).catch(() => null)
|
|
|
|
|
}
|
|
|
|
|
|