Skip to content

refactor(site): use generated Healthcheck API entities #10650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/apitypings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import (

var (
// baseDirs are the directories to introspect for types to generate.
baseDirs = [...]string{"./codersdk", "./coderd/healthcheck", "./coderd/healthcheck/derphealth"}
baseDirs = [...]string{"./codersdk", "./coderd/healthcheck"}
// externalTypes are types that are not in the baseDirs, but we want to
// support. These are usually types that are used in the baseDirs.
// Do not include things like "Database", as that would break the idea
// of splitting db and api types.
// Only include dirs that are client facing packages.
externalTypeDirs = [...]string{"./cli/clibase"}
externalTypeDirs = [...]string{"./cli/clibase", "./coderd/healthcheck/derphealth"}
indent = " "
)

Expand Down
14 changes: 3 additions & 11 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1555,17 +1555,9 @@ export const getInsightsTemplate = async (
return response.data;
};

export interface Health {
healthy: boolean;
time: string;
coder_version: string;
access_url: { healthy: boolean };
database: { healthy: boolean };
derp: { healthy: boolean };
websocket: { healthy: boolean };
}

export const getHealth = async () => {
const response = await axios.get<Health>("/api/v2/debug/health");
const response = await axios.get<TypesGen.HealthcheckReport>(
"/api/v2/debug/health",
);
return response.data;
};
94 changes: 46 additions & 48 deletions site/src/api/typesGenerated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { Health } from "api/api";
import type { DeploymentStats, WorkspaceStatus } from "api/typesGenerated";
import type {
DeploymentStats,
HealthcheckReport,
WorkspaceStatus,
} from "api/typesGenerated";
import {
type FC,
useMemo,
Expand Down Expand Up @@ -67,7 +70,7 @@ const styles = {
} satisfies Record<string, Interpolation<Theme>>;

export interface DeploymentBannerViewProps {
health?: Health;
health?: HealthcheckReport;
stats?: DeploymentStats;
fetchStats?: () => void;
}
Expand Down
Loading