import type { IntegrationAdapter } from './types.js'

export const uptimeKuma: IntegrationAdapter = {
  async testConnection(config) {
    const baseUrl = config.baseUrl?.replace(/\/$/, '')
    if (!baseUrl) return { ok: false, message: 'Missing baseUrl' }
    try {
      const res = await fetch(`${baseUrl}/api/status-page/heartbeat/default`)
      if (!res.ok) return { ok: false, message: `HTTP ${res.status}` }
      return { ok: true, message: 'Connected' }
    } catch (err) {
      return { ok: false, message: err instanceof Error ? err.message : 'Connection failed' }
    }
  },
}
