mirror of
https://github.com/actualbudget/actual.git
synced 2026-10-11 22:49:59 +00:00
[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:
@@ -95,7 +95,7 @@
|
||||
"app.ts",
|
||||
"src/app.ts",
|
||||
"bin/**/*.js",
|
||||
"src/scripts/**/*.js",
|
||||
"src/scripts/**/*.{js,ts}",
|
||||
"src/app-*/app-*.{ts,js}"
|
||||
]
|
||||
}
|
||||
|
||||
+19
-4
@@ -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,
|
||||
);
|
||||
}
|
||||
})
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user