import type { ServiceConfig } from '$lib/config'; import type { ServicePoller } from '../service'; export const config: Partial = { title: 'Pi-hole', logo: 'https://cdn.rawgit.com/pi-hole/graphics/master/Vortex/Vortex.svg', subtitle: 'Sends ads into a black hole' }; export const poll: ServicePoller = async (config: ServiceConfig) => { const resp: Response = await fetch(config.url + '/api.php?summaryRaw&auth=' + config.api_token); const raw = await resp.json(); return { status: resp.ok ? 'online' : 'offline', data: { queries_today: raw.dns_queries_today, ads_percentage: raw.ads_percentage_today, status: raw.status, clients: raw.unique_clients } }; };