diff --git a/package-lock.json b/package-lock.json index 1c96247..c97ef0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mobicoop/ad", - "version": "2.2.2", + "version": "2.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mobicoop/ad", - "version": "2.2.2", + "version": "2.2.3", "license": "AGPL", "dependencies": { "@grpc/grpc-js": "^1.9.5", diff --git a/package.json b/package.json index 8b2c071..817637b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mobicoop/ad", - "version": "2.2.2", + "version": "2.2.3", "description": "Mobicoop V3 Ad", "author": "sbriat", "private": true, diff --git a/src/app.constants.ts b/src/app.constants.ts index a89d54b..921a3b9 100644 --- a/src/app.constants.ts +++ b/src/app.constants.ts @@ -5,6 +5,9 @@ export const SERVICE_NAME = 'ad'; export const GRPC_PACKAGE_NAME = 'ad'; export const GRPC_SERVICE_NAME = 'AdService'; +// messaging +export const AD_CREATED_ROUTING_KEY = 'ad.created'; + // configuration export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set'; export const SERVICE_CONFIGURATION_DELETE_QUEUE = 'ad-configuration-delete'; diff --git a/src/modules/ad/ad.constants.ts b/src/modules/ad/ad.constants.ts deleted file mode 100644 index 415925e..0000000 --- a/src/modules/ad/ad.constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const MESSAGER_AD_CREATED_ROUTING_KEY = 'ad.created'; diff --git a/src/modules/ad/core/application/event-handlers/publish-message-when-ad-is-created.domain-event-handler.ts b/src/modules/ad/core/application/event-handlers/publish-message-when-ad-is-created.domain-event-handler.ts index 24f72fd..1acae44 100644 --- a/src/modules/ad/core/application/event-handlers/publish-message-when-ad-is-created.domain-event-handler.ts +++ b/src/modules/ad/core/application/event-handlers/publish-message-when-ad-is-created.domain-event-handler.ts @@ -3,7 +3,7 @@ import { OnEvent } from '@nestjs/event-emitter'; import { AdCreatedDomainEvent } from '../../domain/events/ad-created.domain-events'; import { MessagePublisherPort } from '@mobicoop/ddd-library'; import { AD_MESSAGE_PUBLISHER } from '@modules/ad/ad.di-tokens'; -import { MESSAGER_AD_CREATED_ROUTING_KEY } from '@modules/ad/ad.constants'; +import { AD_CREATED_ROUTING_KEY } from '@src/app.constants'; @Injectable() export class PublishMessageWhenAdIsCreatedDomainEventHandler { @@ -15,7 +15,7 @@ export class PublishMessageWhenAdIsCreatedDomainEventHandler { @OnEvent(AdCreatedDomainEvent.name, { async: true, promisify: true }) async handle(event: AdCreatedDomainEvent): Promise { this.messagePublisher.publish( - MESSAGER_AD_CREATED_ROUTING_KEY, + AD_CREATED_ROUTING_KEY, JSON.stringify(event), ); } diff --git a/src/modules/ad/tests/unit/core/publish-message-when-ad-is-created.domain-event-handler.spec.ts b/src/modules/ad/tests/unit/core/publish-message-when-ad-is-created.domain-event-handler.spec.ts index 3d0386d..a4c98cb 100644 --- a/src/modules/ad/tests/unit/core/publish-message-when-ad-is-created.domain-event-handler.spec.ts +++ b/src/modules/ad/tests/unit/core/publish-message-when-ad-is-created.domain-event-handler.spec.ts @@ -3,7 +3,7 @@ import { PublishMessageWhenAdIsCreatedDomainEventHandler } from '@modules/ad/cor import { AdCreatedDomainEvent } from '@modules/ad/core/domain/events/ad-created.domain-events'; import { Test, TestingModule } from '@nestjs/testing'; import { AD_MESSAGE_PUBLISHER } from '@modules/ad/ad.di-tokens'; -import { MESSAGER_AD_CREATED_ROUTING_KEY } from '@modules/ad/ad.constants'; +import { AD_CREATED_ROUTING_KEY } from '@src/app.constants'; const mockMessagePublisher = { publish: jest.fn().mockImplementation(), @@ -81,7 +81,7 @@ describe('Publish message when ad is created domain event handler', () => { expect(publishMessageWhenAdIsCreatedDomainEventHandler).toBeDefined(); expect(mockMessagePublisher.publish).toHaveBeenCalledTimes(1); expect(mockMessagePublisher.publish).toHaveBeenCalledWith( - MESSAGER_AD_CREATED_ROUTING_KEY, + AD_CREATED_ROUTING_KEY, '{"id":"some-domain-event-id","aggregateId":"some-aggregate-id","userId":"some-user-id","driver":false,"passenger":true,"frequency":"PUNCTUAL","fromDate":"2023-06-28","toDate":"2023-06-28","schedule":[{"day":3,"time":"07:15","margin":900}],"seatsProposed":3,"seatsRequested":1,"strict":false,"waypoints":[{"position":0,"houseNumber":"5","street":"Avenue Foch","locality":"Nancy","postalCode":"54000","country":"France","lat":48.689445,"lon":6.1765102},{"position":1,"locality":"Paris","postalCode":"75000","country":"France","lat":48.8566,"lon":2.3522}],"metadata":{"timestamp":1687928400000,"correlationId":"some-correlation-id"}}', ); });