fix: add statsConfig to metrics API response
- Add statsConfig field to SSHHostWithCredentials interface - Include statsConfig in resolveHostCredentials baseHost object - Ensures /metrics/:id API returns complete host configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -119,7 +119,11 @@ class SSHConnectionPool {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
client.end();
|
client.end();
|
||||||
reject(new Error("TOTP authentication required but not supported in Server Stats"));
|
reject(
|
||||||
|
new Error(
|
||||||
|
"TOTP authentication required but not supported in Server Stats",
|
||||||
|
),
|
||||||
|
);
|
||||||
} else if (host.password) {
|
} else if (host.password) {
|
||||||
const responses = prompts.map(() => host.password || "");
|
const responses = prompts.map(() => host.password || "");
|
||||||
finish(responses);
|
finish(responses);
|
||||||
@@ -294,6 +298,7 @@ interface SSHHostWithCredentials {
|
|||||||
enableFileManager: boolean;
|
enableFileManager: boolean;
|
||||||
defaultPath: string;
|
defaultPath: string;
|
||||||
tunnelConnections: any[];
|
tunnelConnections: any[];
|
||||||
|
statsConfig?: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
@@ -453,6 +458,7 @@ async function resolveHostCredentials(
|
|||||||
tunnelConnections: host.tunnelConnections
|
tunnelConnections: host.tunnelConnections
|
||||||
? JSON.parse(host.tunnelConnections)
|
? JSON.parse(host.tunnelConnections)
|
||||||
: [],
|
: [],
|
||||||
|
statsConfig: host.statsConfig || undefined,
|
||||||
createdAt: host.createdAt,
|
createdAt: host.createdAt,
|
||||||
updatedAt: host.updatedAt,
|
updatedAt: host.updatedAt,
|
||||||
userId: host.userId,
|
userId: host.userId,
|
||||||
@@ -855,7 +861,10 @@ async function collectMetrics(host: SSHHostWithCredentials): Promise<{
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error && error.message.includes("TOTP authentication required")) {
|
if (
|
||||||
|
error instanceof Error &&
|
||||||
|
error.message.includes("TOTP authentication required")
|
||||||
|
) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
@@ -1032,7 +1041,10 @@ app.get("/metrics/:id", validateHostId, async (req, res) => {
|
|||||||
const metrics = await collectMetrics(host);
|
const metrics = await collectMetrics(host);
|
||||||
res.json({ ...metrics, lastChecked: new Date().toISOString() });
|
res.json({ ...metrics, lastChecked: new Date().toISOString() });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof Error && err.message.includes("TOTP authentication required")) {
|
if (
|
||||||
|
err instanceof Error &&
|
||||||
|
err.message.includes("TOTP authentication required")
|
||||||
|
) {
|
||||||
return res.status(403).json({
|
return res.status(403).json({
|
||||||
error: "TOTP_REQUIRED",
|
error: "TOTP_REQUIRED",
|
||||||
message: "Server Stats unavailable for TOTP-enabled servers",
|
message: "Server Stats unavailable for TOTP-enabled servers",
|
||||||
|
|||||||
Reference in New Issue
Block a user