* Check connection to the Codebuff backend by hitting the /healthz endpoint. * * @returns Promise that resolves to true if connected, false otherwise
()
| 65 | * @returns Promise that resolves to true if connected, false otherwise |
| 66 | */ |
| 67 | public async checkConnection(): Promise<boolean> { |
| 68 | try { |
| 69 | const response = await fetch(`${WEBSITE_URL}/api/healthz`, { |
| 70 | method: 'GET', |
| 71 | signal: AbortSignal.timeout(5000), // 5 second timeout |
| 72 | }) |
| 73 | |
| 74 | if (!response.ok) return false |
| 75 | |
| 76 | const result = await response.json() |
| 77 | return ( |
| 78 | typeof result === 'object' && |
| 79 | result !== null && |
| 80 | 'status' in result && |
| 81 | (result as { status?: unknown }).status === 'ok' |
| 82 | ) |
| 83 | } catch { |
| 84 | return false |
| 85 | } |
| 86 | } |
| 87 | } |
no test coverage detected