Fix prettier issues
All checks were successful
CI / checks (push) Successful in 54s

This commit is contained in:
Peter Smit
2025-09-05 09:56:50 +02:00
parent 409784672c
commit 39d55d908a

View File

@@ -10,28 +10,35 @@ export interface HealthCheckStatus {
}
}
async function checkDatabase(): Promise<{ status: 'healthy' | 'unhealthy'; error?: string }> {
async function checkDatabase(): Promise<{
status: 'healthy' | 'unhealthy'
error?: string
}> {
try {
// Simple query to test database connectivity
await prisma.$queryRaw`SELECT 1`
return {
status: 'healthy'
status: 'healthy',
}
} catch (error) {
return {
status: 'unhealthy',
error: error instanceof Error ? error.message : 'Database connection failed'
error:
error instanceof Error ? error.message : 'Database connection failed',
}
}
}
function createHealthResponse(data: HealthCheckStatus, isHealthy: boolean): Response {
function createHealthResponse(
data: HealthCheckStatus,
isHealthy: boolean,
): Response {
return new Response(JSON.stringify(data), {
status: isHealthy ? 200 : 503,
headers: {
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Content-Type': 'application/json'
}
'Content-Type': 'application/json',
},
})
}
@@ -40,7 +47,7 @@ export async function checkReadiness(): Promise<Response> {
const databaseStatus = await checkDatabase()
const services: HealthCheckStatus['services'] = {
database: databaseStatus
database: databaseStatus,
}
// For readiness: healthy only if all services are healthy
@@ -48,7 +55,7 @@ export async function checkReadiness(): Promise<Response> {
const healthStatus: HealthCheckStatus = {
status: isHealthy ? 'healthy' : 'unhealthy',
services
services,
}
return createHealthResponse(healthStatus, isHealthy)
@@ -58,9 +65,10 @@ export async function checkReadiness(): Promise<Response> {
services: {
database: {
status: 'unhealthy',
error: error instanceof Error ? error.message : 'Readiness check failed'
}
}
error:
error instanceof Error ? error.message : 'Readiness check failed',
},
},
}
return createHealthResponse(errorStatus, false)
@@ -72,7 +80,7 @@ export async function checkLiveness(): Promise<Response> {
// Liveness: Only check if the app process is alive
// No database or external service checks - restarting won't fix those
const healthStatus: HealthCheckStatus = {
status: 'healthy'
status: 'healthy',
// No services reported - we don't check them for liveness
}
@@ -80,7 +88,7 @@ export async function checkLiveness(): Promise<Response> {
} catch (error) {
// This should rarely happen, but if it does, the app needs restart
const errorStatus: HealthCheckStatus = {
status: 'unhealthy'
status: 'unhealthy',
}
return createHealthResponse(errorStatus, false)