diff --git a/package-lock.json b/package-lock.json index 54fca6f..1c96247 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mobicoop/ad", - "version": "2.2.1", + "version": "2.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mobicoop/ad", - "version": "2.2.1", + "version": "2.2.2", "license": "AGPL", "dependencies": { "@grpc/grpc-js": "^1.9.5", diff --git a/package.json b/package.json index 7e4bc55..8b2c071 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mobicoop/ad", - "version": "2.2.1", + "version": "2.2.2", "description": "Mobicoop V3 Ad", "author": "sbriat", "private": true, diff --git a/src/app.constants.ts b/src/app.constants.ts index 9db7ad6..a89d54b 100644 --- a/src/app.constants.ts +++ b/src/app.constants.ts @@ -1,6 +1,10 @@ // service export const SERVICE_NAME = 'ad'; +// grpc +export const GRPC_PACKAGE_NAME = 'ad'; +export const GRPC_SERVICE_NAME = 'AdService'; + // configuration export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set'; export const SERVICE_CONFIGURATION_DELETE_QUEUE = 'ad-configuration-delete'; @@ -8,6 +12,6 @@ export const SERVICE_CONFIGURATION_PROPAGATE_QUEUE = 'ad-configuration-propagate'; // health -export const HEALTH_SERVICE_NAME = 'health'; +export const GRPC_HEALTH_PACKAGE_NAME = 'health'; export const HEALTH_AD_REPOSITORY = 'AdRepository'; export const HEALTH_CRITICAL_LOGGING_KEY = 'logging.ad.health.crit'; diff --git a/src/main.ts b/src/main.ts index 892b16c..6e5a20b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ import { NestFactory } from '@nestjs/core'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { join } from 'path'; import { AppModule } from './app.module'; -import { HEALTH_SERVICE_NAME, SERVICE_NAME } from './app.constants'; +import { GRPC_HEALTH_PACKAGE_NAME, GRPC_PACKAGE_NAME } from './app.constants'; async function bootstrap() { const app = await NestFactory.create(AppModule); @@ -12,7 +12,7 @@ async function bootstrap() { app.connectMicroservice({ transport: Transport.GRPC, options: { - package: [SERVICE_NAME, HEALTH_SERVICE_NAME], + package: [GRPC_PACKAGE_NAME, GRPC_HEALTH_PACKAGE_NAME], protoPath: [ join(__dirname, 'modules/ad/interface/grpc-controllers/ad.proto'), join(__dirname, 'health.proto'), diff --git a/src/modules/ad/interface/grpc-controllers/create-ad.grpc.controller.ts b/src/modules/ad/interface/grpc-controllers/create-ad.grpc.controller.ts index 0cc8b33..e2464a0 100644 --- a/src/modules/ad/interface/grpc-controllers/create-ad.grpc.controller.ts +++ b/src/modules/ad/interface/grpc-controllers/create-ad.grpc.controller.ts @@ -8,6 +8,7 @@ import { RpcExceptionCode } from '@mobicoop/ddd-library'; import { RpcValidationPipe } from '@mobicoop/ddd-library'; import { CreateAdCommand } from '@modules/ad/core/application/commands/create-ad/create-ad.command'; import { AdAlreadyExistsException } from '@modules/ad/core/domain/ad.errors'; +import { GRPC_SERVICE_NAME } from '@src/app.constants'; @UsePipes( new RpcValidationPipe({ @@ -19,7 +20,7 @@ import { AdAlreadyExistsException } from '@modules/ad/core/domain/ad.errors'; export class CreateAdGrpcController { constructor(private readonly commandBus: CommandBus) {} - @GrpcMethod('AdService', 'Create') + @GrpcMethod(GRPC_SERVICE_NAME, 'Create') async create(data: CreateAdRequestDto): Promise { try { const aggregateID: AggregateID = await this.commandBus.execute( diff --git a/src/modules/ad/interface/grpc-controllers/find-ad-by-id.grpc.controller.ts b/src/modules/ad/interface/grpc-controllers/find-ad-by-id.grpc.controller.ts index 66d896f..e1e0c34 100644 --- a/src/modules/ad/interface/grpc-controllers/find-ad-by-id.grpc.controller.ts +++ b/src/modules/ad/interface/grpc-controllers/find-ad-by-id.grpc.controller.ts @@ -9,6 +9,7 @@ import { AdMapper } from '@modules/ad/ad.mapper'; import { NotFoundException } from '@mobicoop/ddd-library'; import { RpcExceptionCode } from '@mobicoop/ddd-library'; import { RpcValidationPipe } from '@mobicoop/ddd-library'; +import { GRPC_SERVICE_NAME } from '@src/app.constants'; @UsePipes( new RpcValidationPipe({ @@ -23,7 +24,7 @@ export class FindAdByIdGrpcController { private readonly queryBus: QueryBus, ) {} - @GrpcMethod('AdService', 'FindOneById') + @GrpcMethod(GRPC_SERVICE_NAME, 'FindOneById') async findOnebyId(data: FindAdByIdRequestDto): Promise { try { const ad: AdEntity = await this.queryBus.execute(