@bhooai/nexus-admin 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhooai/nexus-admin",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "BhooAI Nexus v2 admin SPA — Apps-tab-first, live registry/health/logs/config/users/payments/AI",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/api.ts CHANGED
@@ -67,10 +67,23 @@ export async function getRegistry(): Promise<AppEntry[]> {
67
67
  return data.apps ?? [];
68
68
  }
69
69
 
70
- /** Probe a specific backend's /health directly. */
71
- export async function probeApp(port: number): Promise<{ ok: boolean; name?: string }> {
70
+ /**
71
+ * Probe a registered app's liveness.
72
+ *
73
+ * Frontend/admin are Vite SPAs (HTML for any path) — a 200 on `/` means up.
74
+ * Backend apps expose JSON /health with `{ ok: true }`.
75
+ */
76
+ export async function probeApp(port: number, kind?: string): Promise<{ ok: boolean; name?: string }> {
77
+ const isSpa = kind === 'frontend' || kind === 'admin';
78
+ const path = isSpa ? '/' : '/health';
72
79
  try {
73
- return (await request('/health', {}, port)) as { ok: boolean; name?: string };
80
+ const res = await fetch(`http://localhost:${port}${path}`, {
81
+ method: 'GET',
82
+ signal: AbortSignal.timeout(5000),
83
+ });
84
+ if (isSpa) return { ok: res.ok };
85
+ const data = (await res.json()) as { ok?: boolean; name?: string };
86
+ return { ok: !!data.ok, name: data.name };
74
87
  } catch {
75
88
  return { ok: false };
76
89
  }
package/src/tabs/Apps.tsx CHANGED
@@ -12,7 +12,7 @@ export function Apps() {
12
12
  try {
13
13
  const reg = await getRegistry();
14
14
  const probed = await Promise.all(
15
- reg.map(async (a) => ({ ...a, live: (await probeApp(a.port)).ok })),
15
+ reg.map(async (a) => ({ ...a, live: (await probeApp(a.port, a.kind)).ok })),
16
16
  );
17
17
  if (alive) setApps(probed);
18
18
  setError(null);
@@ -12,7 +12,7 @@ export function Overview() {
12
12
  try {
13
13
  const reg = await getRegistry();
14
14
  const probed = await Promise.all(
15
- reg.map(async (a) => ({ ...a, healthy: (await probeApp(a.port)).ok })),
15
+ reg.map(async (a) => ({ ...a, healthy: (await probeApp(a.port, a.kind)).ok })),
16
16
  );
17
17
  if (alive) setApps(probed);
18
18
  } catch (e) {