status.prompt.ac
${status.ok ? "All watched paths are operational." : "One or more watched paths need attention."}
${cards}const AC = "https://aesthetic.computer";
const escapeHtml = (value) => String(value)
.replaceAll("&", "&")
.replaceAll("<", "<")
.replaceAll(">", ">")
.replaceAll('"', """);
async function timedFetch(fetcher, url, options = {}) {
const started = Date.now();
try {
const response = await fetcher(url, {
redirect: options.redirect || "follow",
signal: AbortSignal.timeout(options.timeout || 8000),
headers: options.headers,
});
return { response, ms: Date.now() - started };
} catch (error) {
return { error: error?.message || String(error), ms: Date.now() - started };
}
}
export async function collectStatus(fetcher = fetch, handle = null) {
const checks = [];
const check = async (id, label, url, validate) => {
const result = await timedFetch(fetcher, url);
let detail = result.error || `HTTP ${result.response?.status || 0}`;
let data;
if (result.response) {
try { data = await result.response.clone().json(); } catch {}
}
const ok = Boolean(result.response?.ok && (!validate || validate(data, result.response)));
if (ok) detail = `HTTP ${result.response.status}`;
checks.push({ id, label, url, ok, ms: result.ms, detail, data });
return { ...result, data, ok };
};
await check("front-door", "Aesthetic Computer", AC);
await check(
"api-docs",
"API abstraction",
`${AC}/api`,
);
await check(
"database-read",
"Database read path",
`${AC}/api/chat-messages?instance=system&limit=1`,
(data) => Array.isArray(data?.messages),
);
await check(
"asset-delivery",
"DigitalOcean asset delivery",
"https://assets.aesthetic.computer/aesthetic-inc/pals.png",
(_, response) => (response.headers.get("content-type") || "").startsWith("image/"),
);
await check(
"upload-presign",
"DigitalOcean upload signing",
`${AC}/presigned-upload-url/png`,
(data) => Boolean(data?.uploadURL && data?.slug),
);
if (handle) {
const encodedHandle = encodeURIComponent(handle);
await check(
"profile",
`${handle} profile`,
`${AC}/api/profile/${encodedHandle}`,
(data) => Boolean(data?.sub),
);
const collection = await check(
"portfolio",
`${handle} painting index`,
`${AC}/media-collection?for=${encodedHandle}/painting`,
(data) => Array.isArray(data?.files),
);
const latestUrl = collection.data?.files?.at(-1);
if (latestUrl) {
await check(
"latest-painting",
`${handle} latest painting`,
latestUrl,
(_, response) => (response.headers.get("content-type") || "").startsWith("image/"),
);
}
}
return {
ok: checks.every((item) => item.ok),
checkedAt: new Date().toISOString(),
...(handle ? { handle } : {}),
checks: checks.map(({ data, ...item }) => item),
};
}
function render(status) {
const cards = status.checks.map((item) => `
${status.ok ? "All watched paths are operational." : "One or more watched paths need attention."}
${cards}