Files
pulsenode/lib/collectors/services/coolify.ts
T
valknarandClaude Sonnet 5 2c84a4c9c2 fix: remove project name badges from the Coolify widget
Coolify was the only service reporting the generic detail field
(project name chips); drop it end to end - collector, type, and the
widget's chip row - rather than leave the plumbing for zero producers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WpxhtQY3CExQdMs4j7MmJe
2026-08-18 16:58:47 +02:00

30 lines
1.0 KiB
TypeScript

import type { CoolifyServiceWidget } from "@/lib/config/schema";
import type { ServiceStat } from "@/lib/types/service-result";
import { serviceBaseUrl } from "./base-url";
async function fetchCoolify<T>(base: string, path: string, apiToken: string): Promise<T> {
const response = await fetch(`${base}${path}`, {
headers: { Authorization: `Bearer ${apiToken}` },
signal: AbortSignal.timeout(5_000),
});
if (!response.ok) {
throw new Error(`Coolify API returned ${response.status}`);
}
return (await response.json()) as T;
}
export async function collectCoolify(widget: CoolifyServiceWidget): Promise<{ stats: ServiceStat[] }> {
const base = serviceBaseUrl(widget);
const [projects, resources] = await Promise.all([
fetchCoolify<unknown[]>(base, "/api/v1/projects", widget.apiToken),
fetchCoolify<unknown[]>(base, "/api/v1/resources", widget.apiToken),
]);
return {
stats: [
{ label: "Projects", value: String(projects.length) },
{ label: "Resources", value: String(resources.length) },
],
};
}