mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 08:12:40 +00:00
update packages
This commit is contained in:
@@ -36,9 +36,9 @@ import { OutputDateTimeTransformer } from './infrastructure/output-datetime-tran
|
||||
import { MatchingRepository } from './infrastructure/matching.repository';
|
||||
import { MatchingMapper } from './matching.mapper';
|
||||
import { CacheModule } from '@nestjs/cache-manager';
|
||||
import { RedisClientOptions } from '@liaoliaots/nestjs-redis';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { redisStore } from 'cache-manager-ioredis-yet';
|
||||
import { RedisClientOptions } from '@songkeys/nestjs-redis';
|
||||
|
||||
const imports = [
|
||||
CqrsModule,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { AdEntity } from '../core/domain/ad.entity';
|
||||
import { AdMapper } from '../ad.mapper';
|
||||
import { ExtendedPrismaRepositoryBase } from '@mobicoop/ddd-library/dist/db/prisma-repository.base';
|
||||
import { Frequency } from '../core/domain/ad.types';
|
||||
import { SERVICE_NAME } from '@src/app.constants';
|
||||
|
||||
export type AdModel = {
|
||||
uuid: string;
|
||||
@@ -38,7 +39,7 @@ export type AdReadModel = AdModel & {
|
||||
};
|
||||
|
||||
/**
|
||||
* The record ready to be sent to the peristence system
|
||||
* The record ready to be sent to the persistence system
|
||||
*/
|
||||
export type AdWriteModel = AdModel & {
|
||||
schedule: {
|
||||
@@ -103,7 +104,7 @@ export class AdRepository
|
||||
eventEmitter,
|
||||
new LoggerBase({
|
||||
logger: new Logger(AdRepository.name),
|
||||
domain: 'matcher',
|
||||
domain: SERVICE_NAME,
|
||||
messagePublisher,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { InjectRedis } from '@liaoliaots/nestjs-redis';
|
||||
import { MatchingRepositoryPort } from '../core/application/ports/matching.repository.port';
|
||||
import { MatchingEntity } from '../core/domain/matching.entity';
|
||||
import { Redis } from 'ioredis';
|
||||
import { MatchingMapper } from '../matching.mapper';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { MatchingNotFoundException } from '../core/domain/matching.errors';
|
||||
import { InjectRedis } from '@songkeys/nestjs-redis';
|
||||
|
||||
const REDIS_MATCHING_TTL = 900;
|
||||
const REDIS_MATCHING_KEY = 'MATCHER:MATCHING';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
@@ -6,10 +6,4 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
|
||||
async onModuleInit() {
|
||||
await this.$connect();
|
||||
}
|
||||
|
||||
async enableShutdownHooks(app: INestApplication) {
|
||||
this.$on('beforeExit', async () => {
|
||||
await app.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,9 +137,8 @@ describe('create-ad.service', () => {
|
||||
AdEntity.create = jest.fn().mockReturnValue({
|
||||
id: '047a6ecf-23d4-4d3e-877c-3225d560a8da',
|
||||
});
|
||||
const result: AggregateID = await createAdService.execute(
|
||||
createAdCommand,
|
||||
);
|
||||
const result: AggregateID =
|
||||
await createAdService.execute(createAdCommand);
|
||||
expect(result).toBe('047a6ecf-23d4-4d3e-877c-3225d560a8da');
|
||||
});
|
||||
it('should create a new ad as passenger', async () => {
|
||||
|
||||
@@ -332,9 +332,8 @@ describe('Match Query Handler', () => {
|
||||
},
|
||||
mockRouteProvider,
|
||||
);
|
||||
const matching: MatchingResult = await matchQueryHandler.execute(
|
||||
matchQuery,
|
||||
);
|
||||
const matching: MatchingResult =
|
||||
await matchQueryHandler.execute(matchQuery);
|
||||
expect(matching.id).toHaveLength(36);
|
||||
expect(MatchingEntity.create).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
@@ -362,9 +361,8 @@ describe('Match Query Handler', () => {
|
||||
},
|
||||
mockRouteProvider,
|
||||
);
|
||||
const matching: MatchingResult = await matchQueryHandler.execute(
|
||||
matchQuery,
|
||||
);
|
||||
const matching: MatchingResult =
|
||||
await matchQueryHandler.execute(matchQuery);
|
||||
expect(matching.id).toBe('a3b10efb-121e-4d08-9198-9f57afdb5e2d');
|
||||
expect(MatchingEntity.create).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
@@ -392,9 +390,8 @@ describe('Match Query Handler', () => {
|
||||
},
|
||||
mockRouteProvider,
|
||||
);
|
||||
const matching: MatchingResult = await matchQueryHandler.execute(
|
||||
matchQuery,
|
||||
);
|
||||
const matching: MatchingResult =
|
||||
await matchQueryHandler.execute(matchQuery);
|
||||
expect(matching.id).toHaveLength(36);
|
||||
expect(MatchingEntity.create).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
@@ -274,9 +274,8 @@ describe('Ad repository', () => {
|
||||
});
|
||||
|
||||
it('should return an empty array of candidates if query does not return Ads', async () => {
|
||||
const candidates: AdEntity[] = await adRepository.getCandidateAds(
|
||||
'someQueryString',
|
||||
);
|
||||
const candidates: AdEntity[] =
|
||||
await adRepository.getCandidateAds('someQueryString');
|
||||
expect(candidates.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { getRedisToken } from '@liaoliaots/nestjs-redis';
|
||||
import { Frequency, Role } from '@modules/ad/core/domain/ad.types';
|
||||
import { Target } from '@modules/ad/core/domain/candidate.types';
|
||||
import { MatchEntity } from '@modules/ad/core/domain/match.entity';
|
||||
@@ -8,6 +7,7 @@ import { MatchingRepository } from '@modules/ad/infrastructure/matching.reposito
|
||||
import { MatchingMapper } from '@modules/ad/matching.mapper';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { getRedisToken } from '@songkeys/nestjs-redis';
|
||||
|
||||
const mockConfigService = {
|
||||
get: jest.fn().mockImplementation((value: string) => {
|
||||
|
||||
@@ -6,6 +6,18 @@ import {
|
||||
MessageBrokerPublisher,
|
||||
} from '@mobicoop/message-broker-module';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import {
|
||||
AD_CREATED_MESSAGE_HANDLER,
|
||||
AD_CREATED_QUEUE,
|
||||
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,
|
||||
} from '@src/app.constants';
|
||||
|
||||
const imports = [
|
||||
MessageBrokerModule.forRootAsync({
|
||||
@@ -15,20 +27,25 @@ const imports = [
|
||||
configService: ConfigService,
|
||||
): Promise<MessageBrokerModuleOptions> => ({
|
||||
uri: configService.get<string>('MESSAGE_BROKER_URI') as string,
|
||||
exchange: configService.get<string>('MESSAGE_BROKER_EXCHANGE') as string,
|
||||
name: 'matcher',
|
||||
exchange: {
|
||||
name: configService.get<string>('MESSAGE_BROKER_EXCHANGE') as string,
|
||||
durable: configService.get<boolean>(
|
||||
'MESSAGE_BROKER_EXCHANGE_DURABILITY',
|
||||
) as boolean,
|
||||
},
|
||||
name: SERVICE_NAME,
|
||||
handlers: {
|
||||
adCreated: {
|
||||
routingKey: 'ad.created',
|
||||
queue: 'matcher-ad-created',
|
||||
[AD_CREATED_MESSAGE_HANDLER]: {
|
||||
routingKey: AD_CREATED_ROUTING_KEY,
|
||||
queue: AD_CREATED_QUEUE,
|
||||
},
|
||||
adUpdated: {
|
||||
routingKey: 'ad.updated',
|
||||
queue: 'matcher-ad-updated',
|
||||
[AD_UPDATED_MESSAGE_HANDLER]: {
|
||||
routingKey: AD_UPDATED_ROUTING_KEY,
|
||||
queue: AD_UPDATED_QUEUE,
|
||||
},
|
||||
adDeleted: {
|
||||
routingKey: 'ad.deleted',
|
||||
queue: 'matcher-ad-deleted',
|
||||
[AD_DELETED_MESSAGE_HANDLER]: {
|
||||
routingKey: AD_DELETED_ROUTING_KEY,
|
||||
queue: AD_DELETED_QUEUE,
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user