Merge branch 'constants' into 'main'

Constants

See merge request v3/service/ad!25
This commit is contained in:
Sylvain Briat 2023-10-17 12:47:45 +00:00
commit ac807bd5e5
6 changed files with 14 additions and 8 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@mobicoop/ad", "name": "@mobicoop/ad",
"version": "2.2.1", "version": "2.2.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@mobicoop/ad", "name": "@mobicoop/ad",
"version": "2.2.1", "version": "2.2.2",
"license": "AGPL", "license": "AGPL",
"dependencies": { "dependencies": {
"@grpc/grpc-js": "^1.9.5", "@grpc/grpc-js": "^1.9.5",

View File

@ -1,6 +1,6 @@
{ {
"name": "@mobicoop/ad", "name": "@mobicoop/ad",
"version": "2.2.1", "version": "2.2.2",
"description": "Mobicoop V3 Ad", "description": "Mobicoop V3 Ad",
"author": "sbriat", "author": "sbriat",
"private": true, "private": true,

View File

@ -1,6 +1,10 @@
// service // service
export const SERVICE_NAME = 'ad'; export const SERVICE_NAME = 'ad';
// grpc
export const GRPC_PACKAGE_NAME = 'ad';
export const GRPC_SERVICE_NAME = 'AdService';
// configuration // configuration
export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set'; export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set';
export const SERVICE_CONFIGURATION_DELETE_QUEUE = 'ad-configuration-delete'; export const SERVICE_CONFIGURATION_DELETE_QUEUE = 'ad-configuration-delete';
@ -8,6 +12,6 @@ export const SERVICE_CONFIGURATION_PROPAGATE_QUEUE =
'ad-configuration-propagate'; 'ad-configuration-propagate';
// health // health
export const HEALTH_SERVICE_NAME = 'health'; export const GRPC_HEALTH_PACKAGE_NAME = 'health';
export const HEALTH_AD_REPOSITORY = 'AdRepository'; export const HEALTH_AD_REPOSITORY = 'AdRepository';
export const HEALTH_CRITICAL_LOGGING_KEY = 'logging.ad.health.crit'; export const HEALTH_CRITICAL_LOGGING_KEY = 'logging.ad.health.crit';

View File

@ -2,7 +2,7 @@ import { NestFactory } from '@nestjs/core';
import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { join } from 'path'; import { join } from 'path';
import { AppModule } from './app.module'; 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() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
@ -12,7 +12,7 @@ async function bootstrap() {
app.connectMicroservice<MicroserviceOptions>({ app.connectMicroservice<MicroserviceOptions>({
transport: Transport.GRPC, transport: Transport.GRPC,
options: { options: {
package: [SERVICE_NAME, HEALTH_SERVICE_NAME], package: [GRPC_PACKAGE_NAME, GRPC_HEALTH_PACKAGE_NAME],
protoPath: [ protoPath: [
join(__dirname, 'modules/ad/interface/grpc-controllers/ad.proto'), join(__dirname, 'modules/ad/interface/grpc-controllers/ad.proto'),
join(__dirname, 'health.proto'), join(__dirname, 'health.proto'),

View File

@ -8,6 +8,7 @@ import { RpcExceptionCode } from '@mobicoop/ddd-library';
import { RpcValidationPipe } from '@mobicoop/ddd-library'; import { RpcValidationPipe } from '@mobicoop/ddd-library';
import { CreateAdCommand } from '@modules/ad/core/application/commands/create-ad/create-ad.command'; import { CreateAdCommand } from '@modules/ad/core/application/commands/create-ad/create-ad.command';
import { AdAlreadyExistsException } from '@modules/ad/core/domain/ad.errors'; import { AdAlreadyExistsException } from '@modules/ad/core/domain/ad.errors';
import { GRPC_SERVICE_NAME } from '@src/app.constants';
@UsePipes( @UsePipes(
new RpcValidationPipe({ new RpcValidationPipe({
@ -19,7 +20,7 @@ import { AdAlreadyExistsException } from '@modules/ad/core/domain/ad.errors';
export class CreateAdGrpcController { export class CreateAdGrpcController {
constructor(private readonly commandBus: CommandBus) {} constructor(private readonly commandBus: CommandBus) {}
@GrpcMethod('AdService', 'Create') @GrpcMethod(GRPC_SERVICE_NAME, 'Create')
async create(data: CreateAdRequestDto): Promise<IdResponse> { async create(data: CreateAdRequestDto): Promise<IdResponse> {
try { try {
const aggregateID: AggregateID = await this.commandBus.execute( const aggregateID: AggregateID = await this.commandBus.execute(

View File

@ -9,6 +9,7 @@ import { AdMapper } from '@modules/ad/ad.mapper';
import { NotFoundException } from '@mobicoop/ddd-library'; import { NotFoundException } from '@mobicoop/ddd-library';
import { RpcExceptionCode } from '@mobicoop/ddd-library'; import { RpcExceptionCode } from '@mobicoop/ddd-library';
import { RpcValidationPipe } from '@mobicoop/ddd-library'; import { RpcValidationPipe } from '@mobicoop/ddd-library';
import { GRPC_SERVICE_NAME } from '@src/app.constants';
@UsePipes( @UsePipes(
new RpcValidationPipe({ new RpcValidationPipe({
@ -23,7 +24,7 @@ export class FindAdByIdGrpcController {
private readonly queryBus: QueryBus, private readonly queryBus: QueryBus,
) {} ) {}
@GrpcMethod('AdService', 'FindOneById') @GrpcMethod(GRPC_SERVICE_NAME, 'FindOneById')
async findOnebyId(data: FindAdByIdRequestDto): Promise<AdResponseDto> { async findOnebyId(data: FindAdByIdRequestDto): Promise<AdResponseDto> {
try { try {
const ad: AdEntity = await this.queryBus.execute( const ad: AdEntity = await this.queryBus.execute(