fix and update
This commit is contained in:
@@ -1,9 +1,23 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { Controller, Get, ServiceUnavailableException } from '@nestjs/common';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { CoreGrpcService } from '../core-grpc.service';
|
||||
|
||||
@Controller('health')
|
||||
export class HealthController {
|
||||
constructor(private readonly core: CoreGrpcService) {}
|
||||
|
||||
@Get()
|
||||
check() {
|
||||
return { status: 'ok', service: 'api-gateway' };
|
||||
async check() {
|
||||
try {
|
||||
await firstValueFrom(this.core.settings.GetSetting({ key: 'PROJECT_NAME' }));
|
||||
return { status: 'ok', service: 'api-gateway', grpc: 'ok' };
|
||||
} catch {
|
||||
throw new ServiceUnavailableException({
|
||||
status: 'error',
|
||||
service: 'api-gateway',
|
||||
grpc: 'unavailable',
|
||||
message: 'Не удалось связаться с sso-core по gRPC'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user