@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 +1 -1
- package/src/api.ts +16 -3
- package/src/tabs/Apps.tsx +1 -1
- package/src/tabs/Overview.tsx +1 -1
package/package.json
CHANGED
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
|
-
/**
|
|
71
|
-
|
|
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
|
-
|
|
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);
|
package/src/tabs/Overview.tsx
CHANGED
|
@@ -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) {
|