extract health to module

This commit is contained in:
sbriat 2023-03-31 10:10:31 +02:00
parent 8bf2be24cc
commit da2e365455
7 changed files with 36 additions and 24 deletions

View File

@ -3,6 +3,7 @@ import { AutomapperModule } from '@automapper/nestjs';
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config'; import { ConfigModule } from '@nestjs/config';
import { ConfigurationModule } from './modules/configuration/configuration.module'; import { ConfigurationModule } from './modules/configuration/configuration.module';
import { HealthModule } from './modules/health/health.module';
import { UsersModule } from './modules/users/users.module'; import { UsersModule } from './modules/users/users.module';
@Module({ @Module({
@ -11,6 +12,7 @@ import { UsersModule } from './modules/users/users.module';
AutomapperModule.forRoot({ strategyInitializer: classes() }), AutomapperModule.forRoot({ strategyInitializer: classes() }),
UsersModule, UsersModule,
ConfigurationModule, ConfigurationModule,
HealthModule,
], ],
controllers: [], controllers: [],
providers: [], providers: [],

View File

@ -9,11 +9,11 @@ async function bootstrap() {
{ {
transport: Transport.GRPC, transport: Transport.GRPC,
options: { options: {
package: 'user', package: ['user', 'health'],
protoPath: join( protoPath: [
__dirname, join(__dirname, 'modules/users/adapters/primaries/user.proto'),
'modules/users/adapters/primaries/user.proto', join(__dirname, 'modules/health/adapters/primaries/health.proto'),
), ],
url: process.env.SERVICE_URL + ':' + process.env.SERVICE_PORT, url: process.env.SERVICE_URL + ':' + process.env.SERVICE_PORT,
loader: { keepCase: true }, loader: { keepCase: true },
}, },

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 {}

View File

@ -33,20 +33,3 @@ message Users {
} }
message Empty {} 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

@ -5,7 +5,6 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
import { CqrsModule } from '@nestjs/cqrs'; import { CqrsModule } from '@nestjs/cqrs';
import { redisStore } from 'cache-manager-ioredis-yet'; import { redisStore } from 'cache-manager-ioredis-yet';
import { DatabaseModule } from '../database/database.module'; import { DatabaseModule } from '../database/database.module';
import { HealthController } from './adapters/primaries/health.controller';
import { UsersController } from './adapters/primaries/users.controller'; import { UsersController } from './adapters/primaries/users.controller';
import { Messager } from './adapters/secondaries/messager'; import { Messager } from './adapters/secondaries/messager';
import { UsersRepository } from './adapters/secondaries/users.repository'; import { UsersRepository } from './adapters/secondaries/users.repository';
@ -47,7 +46,7 @@ import { UserProfile } from './mappers/user.profile';
inject: [ConfigService], inject: [ConfigService],
}), }),
], ],
controllers: [UsersController, HealthController], controllers: [UsersController],
providers: [ providers: [
UserProfile, UserProfile,
UsersRepository, UsersRepository,