extract health to module

This commit is contained in:
sbriat 2023-03-31 10:09:51 +02:00
parent f08622ce35
commit 6a0b33f742
7 changed files with 33 additions and 24 deletions

View File

@ -4,6 +4,7 @@ import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { AuthenticationModule } from './modules/authentication/authentication.module';
import { AuthorizationModule } from './modules/authorization/authorization.module';
import { HealthModule } from './modules/health/health.module';
@Module({
imports: [
@ -11,6 +12,7 @@ import { AuthorizationModule } from './modules/authorization/authorization.modul
AutomapperModule.forRoot({ strategyInitializer: classes() }),
AuthenticationModule,
AuthorizationModule,
HealthModule,
],
controllers: [],
providers: [],

View File

@ -9,7 +9,7 @@ async function bootstrap() {
{
transport: Transport.GRPC,
options: {
package: ['authentication', 'authorization'],
package: ['authentication', 'authorization', 'health'],
protoPath: [
join(
__dirname,
@ -19,6 +19,7 @@ async function bootstrap() {
__dirname,
'modules/authorization/adapters/primaries/authorization.proto',
),
join(__dirname, 'modules/health/adapters/primaries/health.proto'),
],
url: process.env.SERVICE_URL + ':' + process.env.SERVICE_PORT,
loader: { keepCase: true, enums: String },

View File

@ -40,20 +40,3 @@ message Uuid {
}
message Empty {}
service Health {
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
}
message HealthCheckRequest {
string service = 1;
}
message HealthCheckResponse {
enum ServingStatus {
UNKNOWN = 0;
SERVING = 1;
NOT_SERVING = 2;
}
ServingStatus status = 1;
}

View File

@ -16,7 +16,6 @@ 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: [
@ -48,11 +47,7 @@ import { HealthController } from './adapters/primaries/health.controller';
inject: [ConfigService],
}),
],
controllers: [
AuthenticationController,
AuthenticationMessagerController,
HealthController,
],
controllers: [AuthenticationController, AuthenticationMessagerController],
providers: [
AuthenticationProfile,
UsernameProfile,

View File

@ -0,0 +1,21 @@
syntax = "proto3";
package health;
service Health {
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
}
message HealthCheckRequest {
string service = 1;
}
message HealthCheckResponse {
enum ServingStatus {
UNKNOWN = 0;
SERVING = 1;
NOT_SERVING = 2;
}
ServingStatus status = 1;
}

View File

@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { HealthController } from './adapters/primaries/health.controller';
@Module({
controllers: [HealthController],
})
export class HealthModule {}