const SLSKD_URL = process.env.SLSKD_URL || 'https://slskd.jefflix.lol'
const SLSKD_API_KEY = process.env.SLSKD_API_KEY || ''

export async function slskdFetch(
  path: string,
  options: RequestInit = {}
): Promise<Response> {
  const url = `${SLSKD_URL}/api/v0${path}`
  const res = await fetch(url, {
    ...options,
    headers: {
      'X-API-Key': SLSKD_API_KEY,
      'Content-Type': 'application/json',
      ...options.headers,
    },
    cache: 'no-store',
  })
  return res
}
