Fix healthcheck endpoint (#288)

* fix healthcheck db query
This commit is contained in:
Giancarlo Buomprisco
2025-06-18 22:25:51 +07:00
committed by GitHub
parent b4c8c74bd0
commit cada76070f
2 changed files with 23 additions and 4 deletions

View File

@@ -0,0 +1,18 @@
import { expect, test } from '@playwright/test';
// Simple healthcheck test to verify the API is up and the database responds
test.describe('Healthcheck endpoint', () => {
test('returns healthy status', async ({ request }) => {
const response = await request.get('/healthcheck');
expect(response.status()).toBe(200);
const body = await response.json();
expect(body).toEqual(
expect.objectContaining({
services: expect.objectContaining({ database: true }),
}),
);
});
});

View File

@@ -26,11 +26,12 @@ async function getSupabaseHealthCheck() {
try { try {
const client = getSupabaseServerAdminClient(); const client = getSupabaseServerAdminClient();
const { error } = await client.rpc('is_set', { const { data, error } = await client
field_name: 'billing_provider', .from('config')
}); .select('billing_provider')
.single();
return !error; return !error && Boolean(data?.billing_provider);
} catch { } catch {
return false; return false;
} }