feat(phase1d): sase admin-sdk skeleton + endpoint inventory on /projects/sase

This commit is contained in:
Semih
2026-05-13 10:43:07 +00:00
parent e4e734fc66
commit 7b83ef8f11
2 changed files with 112 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
import { saseDb } from "@/lib/db-sase";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { SASE_ADMIN_ENDPOINTS, saseAdminWired } from "@/lib/admin-sdk/sase";
async function getSaseStats() {
try {
@@ -37,21 +38,52 @@ export async function SaseHealth() {
);
}
const wired = saseAdminWired();
return (
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
<Stat label="Connection" value="healthy" badge="ok" />
<Stat label="Total users" value={stats.users.toString()} hint="public.users" />
<Stat
label="New users (7d)"
value={stats.recentUsers.toString()}
hint="created_at last 7 days"
/>
<Stat
label="Active subscriptions"
value={`${stats.activeSubs} / ${stats.totalSubs}`}
hint="status='active'"
/>
</div>
<>
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
<Stat label="Connection" value="healthy" badge="ok" />
<Stat label="Total users" value={stats.users.toString()} hint="public.users" />
<Stat
label="New users (7d)"
value={stats.recentUsers.toString()}
hint="created_at last 7 days"
/>
<Stat
label="Active subscriptions"
value={`${stats.activeSubs} / ${stats.totalSubs}`}
hint="status='active'"
/>
</div>
<Card>
<CardHeader>
<CardDescription>Admin SDK</CardDescription>
<CardTitle className="flex items-center gap-2 text-base">
{wired ? (
<Badge>{SASE_ADMIN_ENDPOINTS.length} endpoints wired</Badge>
) : (
<Badge variant="outline">not wired</Badge>
)}
</CardTitle>
</CardHeader>
<CardContent className="space-y-2 text-sm">
{!wired && (
<p className="text-muted-foreground">
Set <code>SASE_ADMIN_API_BASE</code> and{" "}
<code>INTERNAL_API_TOKEN_SASE</code> in Coolify env when spoke ships
the <code>/internal/admin/*</code> endpoints.
</p>
)}
<ul className="space-y-1 font-mono text-xs text-muted-foreground">
{SASE_ADMIN_ENDPOINTS.map((e) => (
<li key={e}>{e}</li>
))}
</ul>
</CardContent>
</Card>
</>
);
}