clean using es6

This commit is contained in:
sbriat
2023-05-05 16:56:30 +02:00
parent 0ca7a4d65e
commit f430a4bfb6
28 changed files with 484 additions and 320 deletions

View File

@@ -19,7 +19,7 @@ interface HealthCheckResponse {
@Controller()
export class HealthServerController {
constructor(
private readonly _prismaHealthIndicatorUseCase: PrismaHealthIndicatorUseCase,
private readonly prismaHealthIndicatorUseCase: PrismaHealthIndicatorUseCase,
) {}
@GrpcMethod('Health', 'Check')
@@ -29,7 +29,7 @@ export class HealthServerController {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
metadata: any,
): Promise<HealthCheckResponse> {
const healthCheck = await this._prismaHealthIndicatorUseCase.isHealthy(
const healthCheck = await this.prismaHealthIndicatorUseCase.isHealthy(
'prisma',
);
return {

View File

@@ -10,21 +10,21 @@ import { PrismaHealthIndicatorUseCase } from '../../domain/usecases/prisma.healt
@Controller('health')
export class HealthController {
constructor(
private readonly _prismaHealthIndicatorUseCase: PrismaHealthIndicatorUseCase,
private _healthCheckService: HealthCheckService,
private _messager: Messager,
private readonly prismaHealthIndicatorUseCase: PrismaHealthIndicatorUseCase,
private readonly healthCheckService: HealthCheckService,
private readonly messager: Messager,
) {}
@Get()
@HealthCheck()
async check() {
try {
return await this._healthCheckService.check([
async () => this._prismaHealthIndicatorUseCase.isHealthy('prisma'),
return await this.healthCheckService.check([
async () => this.prismaHealthIndicatorUseCase.isHealthy('prisma'),
]);
} catch (error) {
const healthCheckResult: HealthCheckResult = error.response;
this._messager.publish(
this.messager.publish(
'logging.user.health.crit',
JSON.stringify(healthCheckResult.error),
);

View File

@@ -6,13 +6,13 @@ import { IMessageBroker } from './message-broker';
@Injectable()
export class Messager extends IMessageBroker {
constructor(
private readonly _amqpConnection: AmqpConnection,
configService: ConfigService,
private readonly amqpConnection: AmqpConnection,
private readonly configService: ConfigService,
) {
super(configService.get<string>('RMQ_EXCHANGE'));
}
publish(routingKey: string, message: string): void {
this._amqpConnection.publish(this.exchange, routingKey, message);
}
publish = (routingKey: string, message: string): void => {
this.amqpConnection.publish(this.exchange, routingKey, message);
};
}

View File

@@ -8,18 +8,18 @@ import { UsersRepository } from '../../../user/adapters/secondaries/users.reposi
@Injectable()
export class PrismaHealthIndicatorUseCase extends HealthIndicator {
constructor(private readonly _repository: UsersRepository) {
constructor(private readonly repository: UsersRepository) {
super();
}
async isHealthy(key: string): Promise<HealthIndicatorResult> {
isHealthy = async (key: string): Promise<HealthIndicatorResult> => {
try {
await this._repository.healthCheck();
await this.repository.healthCheck();
return this.getStatus(key, true);
} catch (e) {
throw new HealthCheckError('Prisma', {
prisma: e.message,
});
}
}
};
}