From a0536d852f114408181f18832d9477f25dc7d13a Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Fri, 5 Jul 2024 23:05:19 +0100 Subject: [PATCH] cleanup indicators --- .../server/src/integrations/health/postgres.health.ts | 11 ++--------- apps/server/src/integrations/health/redis.health.ts | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/apps/server/src/integrations/health/postgres.health.ts b/apps/server/src/integrations/health/postgres.health.ts index d98ba3d..07b4cb3 100644 --- a/apps/server/src/integrations/health/postgres.health.ts +++ b/apps/server/src/integrations/health/postgres.health.ts @@ -17,21 +17,14 @@ export class PostgresHealthIndicator extends HealthIndicator { } async pingCheck(key: string): Promise { - let isHealthy = false; - try { await sql`SELECT 1=1`.execute(this.db); - isHealthy = true; + return this.getStatus(key, true); } catch (e) { this.logger.error(JSON.stringify(e)); - } - - if (isHealthy) { - return this.getStatus(key, isHealthy); - } else { throw new HealthCheckError( `${key} is not available`, - this.getStatus(key, isHealthy), + this.getStatus(key, false), ); } } diff --git a/apps/server/src/integrations/health/redis.health.ts b/apps/server/src/integrations/health/redis.health.ts index 454ac4e..1b4e1f6 100644 --- a/apps/server/src/integrations/health/redis.health.ts +++ b/apps/server/src/integrations/health/redis.health.ts @@ -16,25 +16,18 @@ export class RedisHealthIndicator extends HealthIndicator { } async pingCheck(key: string): Promise { - let isHealthy = false; - try { const redis = new Redis(this.environmentService.getRedisUrl(), { maxRetriesPerRequest: 15, }); await redis.ping(); - isHealthy = true; + return this.getStatus(key, true); } catch (e) { this.logger.error(e); - } - - if (isHealthy) { - return this.getStatus(key, isHealthy); - } else { throw new HealthCheckError( `${key} is not available`, - this.getStatus(key, isHealthy), + this.getStatus(key, false), ); } }