[AI] Migrate health-check script to TypeScript (#8599)

* [AI] Migrate health-check script to TypeScript

* [AI] Include TypeScript scripts in knip entries

* [AI] Validate health status response type
This commit is contained in:
Anju
2026-08-22 22:32:16 +00:00
committed by GitHub
parent 967b4443d5
commit 3ac0d7309b
4 changed files with 27 additions and 6 deletions
+1 -1
View File
@@ -95,7 +95,7 @@
"app.ts",
"src/app.ts",
"bin/**/*.js",
"src/scripts/**/*.js",
"src/scripts/**/*.{js,ts}",
"src/app-*/app-*.{ts,js}"
]
}
@@ -5,13 +5,28 @@ const protocol =
const hostname =
config.get('hostname') === '::' ? 'localhost' : config.get('hostname');
function getHealthStatus(response: unknown): string | undefined {
if (
typeof response === 'object' &&
response !== null &&
'status' in response &&
typeof response.status === 'string'
) {
return response.status;
}
return undefined;
}
fetch(`${protocol}://${hostname}:${config.get('port')}/health`)
.then(res => res.json())
.then(res => {
if (res.status !== 'UP') {
.then(response => response.json())
.then(response => {
const status = getHealthStatus(response);
if (status !== 'UP') {
throw new Error(
'Health check failed: Server responded to health check with status ' +
res.status,
status,
);
}
})
+1 -1
View File
@@ -55,7 +55,7 @@ export default defineConfig({
),
'scripts/health-check': path.resolve(
__dirname,
'src/scripts/health-check.js',
'src/scripts/health-check.ts',
),
},
output: {
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [anjupathak03]
---
Migrate the sync-server health-check script to TypeScript