Skip to content

Commit fbd3413

Browse files
authored
refactor(site): use generated Healthcheck API entities (#10650)
1 parent b69c237 commit fbd3413

File tree

5 files changed

+104
-110
lines changed

5 files changed

+104
-110
lines changed

scripts/apitypings/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import (
2828

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

site/src/api/api.ts

+3-11
Original file line numberDiff line numberDiff line change
@@ -1555,17 +1555,9 @@ export const getInsightsTemplate = async (
15551555
return response.data;
15561556
};
15571557

1558-
export interface Health {
1559-
healthy: boolean;
1560-
time: string;
1561-
coder_version: string;
1562-
access_url: { healthy: boolean };
1563-
database: { healthy: boolean };
1564-
derp: { healthy: boolean };
1565-
websocket: { healthy: boolean };
1566-
}
1567-
15681558
export const getHealth = async () => {
1569-
const response = await axios.get<Health>("/api/v2/debug/health");
1559+
const response = await axios.get<TypesGen.HealthcheckReport>(
1560+
"/api/v2/debug/health",
1561+
);
15701562
return response.data;
15711563
};

site/src/api/typesGenerated.ts

+46-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import type { Health } from "api/api";
2-
import type { DeploymentStats, WorkspaceStatus } from "api/typesGenerated";
1+
import type {
2+
DeploymentStats,
3+
HealthcheckReport,
4+
WorkspaceStatus,
5+
} from "api/typesGenerated";
36
import {
47
type FC,
58
useMemo,
@@ -67,7 +70,7 @@ const styles = {
6770
} satisfies Record<string, Interpolation<Theme>>;
6871

6972
export interface DeploymentBannerViewProps {
70-
health?: Health;
73+
health?: HealthcheckReport;
7174
stats?: DeploymentStats;
7275
fetchStats?: () => void;
7376
}

0 commit comments

Comments
 (0)