Merge branch 'fixAdValidation' into 'main'
Fix ad validation See merge request v3/service/matcher!24
This commit is contained in:
commit
d172cac7f4
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@mobicoop/matcher",
|
"name": "@mobicoop/matcher",
|
||||||
"version": "1.5.0",
|
"version": "1.5.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@mobicoop/matcher",
|
"name": "@mobicoop/matcher",
|
||||||
"version": "1.5.0",
|
"version": "1.5.1",
|
||||||
"license": "AGPL",
|
"license": "AGPL",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.9.9",
|
"@grpc/grpc-js": "^1.9.9",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@mobicoop/matcher",
|
"name": "@mobicoop/matcher",
|
||||||
"version": "1.5.0",
|
"version": "1.5.1",
|
||||||
"description": "Mobicoop V3 Matcher",
|
"description": "Mobicoop V3 Matcher",
|
||||||
"author": "sbriat",
|
"author": "sbriat",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|
|
@ -4,19 +4,15 @@ export const SERVICE_NAME = 'matcher';
|
||||||
// grpc
|
// grpc
|
||||||
export const GRPC_PACKAGE_NAME = 'matcher';
|
export const GRPC_PACKAGE_NAME = 'matcher';
|
||||||
|
|
||||||
// messaging
|
// messaging output
|
||||||
|
export const MATCHER_AD_CREATED_ROUTING_KEY = 'matcher-ad.created';
|
||||||
|
export const MATCHER_AD_CREATION_FAILED_ROUTING_KEY =
|
||||||
|
'matcher-ad.creation-failed';
|
||||||
|
|
||||||
|
// messaging input
|
||||||
export const AD_CREATED_MESSAGE_HANDLER = 'adCreated';
|
export const AD_CREATED_MESSAGE_HANDLER = 'adCreated';
|
||||||
export const AD_CREATED_ROUTING_KEY = 'ad.created';
|
export const AD_CREATED_ROUTING_KEY = 'ad.created';
|
||||||
export const AD_CREATED_QUEUE = 'matcher-ad-created';
|
export const AD_CREATED_QUEUE = 'matcher.ad.created';
|
||||||
export const AD_UPDATED_MESSAGE_HANDLER = 'adUpdated';
|
|
||||||
export const AD_UPDATED_ROUTING_KEY = 'ad.updated';
|
|
||||||
export const AD_UPDATED_QUEUE = 'matcher-ad-updated';
|
|
||||||
export const AD_DELETED_MESSAGE_HANDLER = 'adDeleted';
|
|
||||||
export const AD_DELETED_ROUTING_KEY = 'ad.deleted';
|
|
||||||
export const AD_DELETED_QUEUE = 'matcher-ad-deleted';
|
|
||||||
export const MATCHER_AD_CREATED_ROUTING_KEY = 'matcher.ad.created';
|
|
||||||
export const MATCHER_AD_CREATION_FAILED_ROUTING_KEY =
|
|
||||||
'matcher.ad.creation.failed';
|
|
||||||
|
|
||||||
// health
|
// health
|
||||||
export const GRPC_HEALTH_PACKAGE_NAME = 'health';
|
export const GRPC_HEALTH_PACKAGE_NAME = 'health';
|
||||||
|
|
|
@ -3,7 +3,10 @@ import { RabbitSubscribe } from '@mobicoop/message-broker-module';
|
||||||
import { CommandBus } from '@nestjs/cqrs';
|
import { CommandBus } from '@nestjs/cqrs';
|
||||||
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 { Ad } from './ad.types';
|
import { Ad } from './ad.types';
|
||||||
import { AD_CREATED_MESSAGE_HANDLER } from '@src/app.constants';
|
import {
|
||||||
|
AD_CREATED_MESSAGE_HANDLER,
|
||||||
|
AD_CREATED_ROUTING_KEY,
|
||||||
|
} from '@src/app.constants';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdCreatedMessageHandler {
|
export class AdCreatedMessageHandler {
|
||||||
|
@ -11,23 +14,29 @@ export class AdCreatedMessageHandler {
|
||||||
|
|
||||||
@RabbitSubscribe({
|
@RabbitSubscribe({
|
||||||
name: AD_CREATED_MESSAGE_HANDLER,
|
name: AD_CREATED_MESSAGE_HANDLER,
|
||||||
|
routingKey: AD_CREATED_ROUTING_KEY,
|
||||||
})
|
})
|
||||||
public async adCreated(message: string) {
|
public async adCreated(message: string) {
|
||||||
const createdAd: Ad = JSON.parse(message);
|
try {
|
||||||
await this.commandBus.execute(
|
const createdAd: Ad = JSON.parse(message);
|
||||||
new CreateAdCommand({
|
await this.commandBus.execute(
|
||||||
id: createdAd.aggregateId,
|
new CreateAdCommand({
|
||||||
driver: createdAd.driver,
|
id: createdAd.aggregateId,
|
||||||
passenger: createdAd.passenger,
|
driver: createdAd.driver,
|
||||||
frequency: createdAd.frequency,
|
passenger: createdAd.passenger,
|
||||||
fromDate: createdAd.fromDate,
|
frequency: createdAd.frequency,
|
||||||
toDate: createdAd.toDate,
|
fromDate: createdAd.fromDate,
|
||||||
schedule: createdAd.schedule,
|
toDate: createdAd.toDate,
|
||||||
seatsProposed: createdAd.seatsProposed,
|
schedule: createdAd.schedule,
|
||||||
seatsRequested: createdAd.seatsRequested,
|
seatsProposed: createdAd.seatsProposed,
|
||||||
strict: createdAd.strict,
|
seatsRequested: createdAd.seatsRequested,
|
||||||
waypoints: createdAd.waypoints,
|
strict: createdAd.strict,
|
||||||
}),
|
waypoints: createdAd.waypoints,
|
||||||
);
|
}),
|
||||||
|
);
|
||||||
|
} catch (error: any) {
|
||||||
|
// do not throw error to acknowledge incoming message
|
||||||
|
// error handling should be done in the command handler, if relevant
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,6 @@ import {
|
||||||
AD_CREATED_MESSAGE_HANDLER,
|
AD_CREATED_MESSAGE_HANDLER,
|
||||||
AD_CREATED_QUEUE,
|
AD_CREATED_QUEUE,
|
||||||
AD_CREATED_ROUTING_KEY,
|
AD_CREATED_ROUTING_KEY,
|
||||||
AD_DELETED_MESSAGE_HANDLER,
|
|
||||||
AD_DELETED_QUEUE,
|
|
||||||
AD_DELETED_ROUTING_KEY,
|
|
||||||
AD_UPDATED_MESSAGE_HANDLER,
|
|
||||||
AD_UPDATED_QUEUE,
|
|
||||||
AD_UPDATED_ROUTING_KEY,
|
|
||||||
SERVICE_NAME,
|
SERVICE_NAME,
|
||||||
} from '@src/app.constants';
|
} from '@src/app.constants';
|
||||||
|
|
||||||
|
@ -39,14 +33,6 @@ const imports = [
|
||||||
routingKey: AD_CREATED_ROUTING_KEY,
|
routingKey: AD_CREATED_ROUTING_KEY,
|
||||||
queue: AD_CREATED_QUEUE,
|
queue: AD_CREATED_QUEUE,
|
||||||
},
|
},
|
||||||
[AD_UPDATED_MESSAGE_HANDLER]: {
|
|
||||||
routingKey: AD_UPDATED_ROUTING_KEY,
|
|
||||||
queue: AD_UPDATED_QUEUE,
|
|
||||||
},
|
|
||||||
[AD_DELETED_MESSAGE_HANDLER]: {
|
|
||||||
routingKey: AD_DELETED_ROUTING_KEY,
|
|
||||||
queue: AD_DELETED_QUEUE,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue