Sync source readiness endpoint

This commit is contained in:
Admin 2026-09-29 05:58:36 +00:00
parent f163f21104
commit 82c7bdd196

View File

@ -18,6 +18,37 @@ app.get("/health", async (_req, res) => {
}
});
app.get("/ready", async (_req, res) => {
try {
const result = await pool.query(
`SELECT s.id, s.name, s.last_synced_at, s.last_error,
COUNT(sig.id)::int AS signal_count
FROM sources s
LEFT JOIN signals sig ON sig.source_id=s.id
GROUP BY s.id,s.name,s.last_synced_at,s.last_error
ORDER BY s.id`
);
const missing = result.rows
.filter((row: any) => Number(row.signal_count) < 1)
.map((row: any) => row.id);
const errored = result.rows
.filter((row: any) => row.last_error)
.map((row: any) => row.id);
if (missing.length || errored.length) {
return res.status(503).json({
ok: false,
missing_sources: missing,
errored_sources: errored,
sources: result.rows
});
}
return res.json({ ok: true, sources: result.rows });
} catch (error) {
return res.status(503).json({ ok: false, error: error instanceof Error ? error.message : String(error) });
}
});
app.get("/.well-known/oauth-protected-resource", (req, res) => res.json(protectedResourceMetadata(req)));
app.get("/.well-known/oauth-protected-resource/api/mcp", (req, res) => res.json(protectedResourceMetadata(req)));