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();
|
||||
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) {
|
||||
const responses = prompts.map(() => host.password || "");
|
||||
finish(responses);
|
||||
@@ -294,6 +298,7 @@ interface SSHHostWithCredentials {
|
||||
enableFileManager: boolean;
|
||||
defaultPath: string;
|
||||
tunnelConnections: any[];
|
||||
statsConfig?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
userId: string;
|
||||
@@ -453,6 +458,7 @@ async function resolveHostCredentials(
|
||||
tunnelConnections: host.tunnelConnections
|
||||
? JSON.parse(host.tunnelConnections)
|
||||
: [],
|
||||
statsConfig: host.statsConfig || undefined,
|
||||
createdAt: host.createdAt,
|
||||
updatedAt: host.updatedAt,
|
||||
userId: host.userId,
|
||||
@@ -855,7 +861,10 @@ async function collectMetrics(host: SSHHostWithCredentials): Promise<{
|
||||
return result;
|
||||
});
|
||||
} 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;
|
||||
@@ -1032,7 +1041,10 @@ app.get("/metrics/:id", validateHostId, async (req, res) => {
|
||||
const metrics = await collectMetrics(host);
|
||||
res.json({ ...metrics, lastChecked: new Date().toISOString() });
|
||||
} 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({
|
||||
error: "TOTP_REQUIRED",
|
||||
message: "Server Stats unavailable for TOTP-enabled servers",
|
||||
|
||||
Reference in New Issue
Block a user