upgrade to NestJS 11 (#766)

* upgrade to nest 11

* update dependencies
This commit is contained in:
Philip Okugbe
2025-02-20 21:17:03 +00:00
committed by GitHub
parent 3e5cb92621
commit 64ecef09bc
5 changed files with 2985 additions and 2570 deletions

View File

@ -1,31 +1,30 @@
import { InjectKysely } from 'nestjs-kysely';
import {
HealthCheckError,
HealthIndicator,
HealthIndicatorResult,
HealthIndicatorService,
} from '@nestjs/terminus';
import { Injectable, Logger } from '@nestjs/common';
import { sql } from 'kysely';
import { KyselyDB } from '@docmost/db/types/kysely.types';
@Injectable()
export class PostgresHealthIndicator extends HealthIndicator {
export class PostgresHealthIndicator {
private readonly logger = new Logger(PostgresHealthIndicator.name);
constructor(@InjectKysely() private readonly db: KyselyDB) {
super();
}
constructor(
private readonly healthIndicatorService: HealthIndicatorService,
@InjectKysely() private readonly db: KyselyDB,
) {}
async pingCheck(key: string): Promise<HealthIndicatorResult> {
const indicator = this.healthIndicatorService.check(key);
try {
await sql`SELECT 1=1`.execute(this.db);
return this.getStatus(key, true);
return indicator.up();
} catch (e) {
this.logger.error(JSON.stringify(e));
throw new HealthCheckError(
`${key} is not available`,
this.getStatus(key, false),
);
return indicator.down(`${key} is not available`);
}
}
}

View File

@ -1,21 +1,23 @@
import {
HealthCheckError,
HealthIndicator,
HealthIndicatorResult,
HealthIndicatorService,
} from '@nestjs/terminus';
import { Injectable, Logger } from '@nestjs/common';
import { EnvironmentService } from '../environment/environment.service';
import { Redis } from 'ioredis';
@Injectable()
export class RedisHealthIndicator extends HealthIndicator {
export class RedisHealthIndicator {
private readonly logger = new Logger(RedisHealthIndicator.name);
constructor(private environmentService: EnvironmentService) {
super();
}
constructor(
private readonly healthIndicatorService: HealthIndicatorService,
private environmentService: EnvironmentService,
) {}
async pingCheck(key: string): Promise<HealthIndicatorResult> {
const indicator = this.healthIndicatorService.check(key);
try {
const redis = new Redis(this.environmentService.getRedisUrl(), {
maxRetriesPerRequest: 15,
@ -23,13 +25,10 @@ export class RedisHealthIndicator extends HealthIndicator {
await redis.ping();
redis.disconnect();
return this.getStatus(key, true);
return indicator.up();
} catch (e) {
this.logger.error(e);
throw new HealthCheckError(
`${key} is not available`,
this.getStatus(key, false),
);
return indicator.down(`${key} is not available`);
}
}
}