chore: switch to shared healtcheck func

This commit is contained in:
Aarnav Tale 2025-01-18 07:38:55 +00:00
parent 51fa7c14d0
commit 539c76dfb3
No known key found for this signature in database

View File

@ -20,6 +20,22 @@ export class FatalError extends Error {
}
}
export async function healthcheck() {
const context = await loadContext();
const prefix = context.headscaleUrl;
log.debug('APIC', 'GET /health');
const health = new URL('health', prefix);
const response = await fetch(health.toString(), {
headers: {
Accept: 'application/json'
}
})
// Intentionally not catching
return response.status === 200;
}
export async function pull<T>(url: string, key: string) {
if (!key || key === 'undefined' || key.length === 0) {
throw new Error('Missing API key, could this be a cookie setting issue?');