Merge branch 'improveHealth' into 'main'
improve healthcheck service See merge request v3/service/auth!28
This commit is contained in:
commit
f08622ce35
|
@ -24,12 +24,6 @@ import { AuthenticationPresenter } from './authentication.presenter';
|
|||
import { RpcValidationPipe } from '../../../../utils/pipes/rpc.validation-pipe';
|
||||
import { UsernamePresenter } from './username.presenter';
|
||||
|
||||
enum ServingStatus {
|
||||
UNKNOWN = 0,
|
||||
SERVING = 1,
|
||||
NOT_SERVING = 2,
|
||||
}
|
||||
|
||||
@UsePipes(
|
||||
new RpcValidationPipe({
|
||||
whitelist: true,
|
||||
|
@ -191,11 +185,4 @@ export class AuthenticationController {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
@GrpcMethod('Health', 'Check')
|
||||
async check(): Promise<{ status: ServingStatus }> {
|
||||
return {
|
||||
status: ServingStatus.SERVING,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import { Controller } from '@nestjs/common';
|
||||
import { GrpcMethod } from '@nestjs/microservices';
|
||||
|
||||
enum ServingStatus {
|
||||
UNKNOWN = 0,
|
||||
SERVING = 1,
|
||||
NOT_SERVING = 2,
|
||||
}
|
||||
|
||||
interface HealthCheckRequest {
|
||||
service: string;
|
||||
}
|
||||
|
||||
interface HealthCheckResponse {
|
||||
status: ServingStatus;
|
||||
}
|
||||
|
||||
@Controller()
|
||||
export class HealthController {
|
||||
@GrpcMethod('Health', 'Check')
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
check(data: HealthCheckRequest, metadata: any): HealthCheckResponse {
|
||||
return {
|
||||
status: ServingStatus.SERVING,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import { RabbitMQModule } from '@golevelup/nestjs-rabbitmq';
|
|||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { AuthenticationMessagerController } from './adapters/primaries/authentication-messager.controller';
|
||||
import { Messager } from './adapters/secondaries/messager';
|
||||
import { HealthController } from './adapters/primaries/health.controller';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -47,7 +48,11 @@ import { Messager } from './adapters/secondaries/messager';
|
|||
inject: [ConfigService],
|
||||
}),
|
||||
],
|
||||
controllers: [AuthenticationController, AuthenticationMessagerController],
|
||||
controllers: [
|
||||
AuthenticationController,
|
||||
AuthenticationMessagerController,
|
||||
HealthController,
|
||||
],
|
||||
providers: [
|
||||
AuthenticationProfile,
|
||||
UsernameProfile,
|
||||
|
|
Loading…
Reference in New Issue