pretty, lint
This commit is contained in:
parent
106c225ee3
commit
3cf2667f92
|
@ -155,17 +155,17 @@ The app exposes the following [gRPC](https://grpc.io/) services :
|
||||||
{
|
{
|
||||||
"day": 1,
|
"day": 1,
|
||||||
"time": "07:00",
|
"time": "07:00",
|
||||||
"margin": 600,
|
"margin": 600
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"day": 2,
|
"day": 2,
|
||||||
"time": "07:05",
|
"time": "07:05",
|
||||||
"margin": 600,
|
"margin": 600
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"day": 5,
|
"day": 5,
|
||||||
"time": "07:10",
|
"time": "07:10",
|
||||||
"margin": 600,
|
"margin": 600
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"waypoints": [
|
"waypoints": [
|
||||||
|
|
|
@ -26,10 +26,14 @@ import { HEALTH_CRITICAL_LOGGING_KEY, SERVICE_NAME } from './app.constants';
|
||||||
useFactory: async (
|
useFactory: async (
|
||||||
configService: ConfigService,
|
configService: ConfigService,
|
||||||
): Promise<ConfigurationModuleOptions> => ({
|
): Promise<ConfigurationModuleOptions> => ({
|
||||||
domain: configService.get<string>('SERVICE_CONFIGURATION_DOMAIN') as string,
|
domain: configService.get<string>(
|
||||||
|
'SERVICE_CONFIGURATION_DOMAIN',
|
||||||
|
) as string,
|
||||||
messageBroker: {
|
messageBroker: {
|
||||||
uri: configService.get<string>('MESSAGE_BROKER_URI') as string,
|
uri: configService.get<string>('MESSAGE_BROKER_URI') as string,
|
||||||
exchange: configService.get<string>('MESSAGE_BROKER_EXCHANGE') as string,
|
exchange: configService.get<string>(
|
||||||
|
'MESSAGE_BROKER_EXCHANGE',
|
||||||
|
) as string,
|
||||||
},
|
},
|
||||||
redis: {
|
redis: {
|
||||||
host: configService.get<string>('REDIS_HOST') as string,
|
host: configService.get<string>('REDIS_HOST') as string,
|
||||||
|
|
|
@ -81,11 +81,6 @@ const adapters: Provider[] = [
|
||||||
...orms,
|
...orms,
|
||||||
...adapters,
|
...adapters,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [PrismaService, AdMapper, AD_REPOSITORY, TIMEZONE_FINDER],
|
||||||
PrismaService,
|
|
||||||
AdMapper,
|
|
||||||
AD_REPOSITORY,
|
|
||||||
TIMEZONE_FINDER,
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
export class AdModule {}
|
export class AdModule {}
|
||||||
|
|
|
@ -15,26 +15,48 @@ import { DateTimeTransformerPort } from '../../ports/datetime-transformer.port';
|
||||||
|
|
||||||
@CommandHandler(CreateAdCommand)
|
@CommandHandler(CreateAdCommand)
|
||||||
export class CreateAdService implements ICommandHandler {
|
export class CreateAdService implements ICommandHandler {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(AD_REPOSITORY)
|
@Inject(AD_REPOSITORY)
|
||||||
private readonly repository: AdRepositoryPort,
|
private readonly repository: AdRepositoryPort,
|
||||||
@Inject(INPUT_DATETIME_TRANSFORMER)
|
@Inject(INPUT_DATETIME_TRANSFORMER)
|
||||||
private readonly datetimeTransformer: DateTimeTransformerPort,
|
private readonly datetimeTransformer: DateTimeTransformerPort,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
async execute(command: CreateAdCommand): Promise<AggregateID> {
|
async execute(command: CreateAdCommand): Promise<AggregateID> {
|
||||||
const ad = AdEntity.create(
|
const ad = AdEntity.create({
|
||||||
{
|
userId: command.userId,
|
||||||
userId: command.userId,
|
driver: command.driver,
|
||||||
driver: command.driver,
|
passenger: command.passenger,
|
||||||
passenger: command.passenger,
|
frequency: command.frequency,
|
||||||
frequency: command.frequency,
|
fromDate: this.datetimeTransformer.fromDate(
|
||||||
fromDate: this.datetimeTransformer.fromDate(
|
{
|
||||||
|
date: command.fromDate,
|
||||||
|
time: command.schedule[0].time,
|
||||||
|
coordinates: {
|
||||||
|
lon: command.waypoints[0].lon,
|
||||||
|
lat: command.waypoints[0].lat,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
command.frequency,
|
||||||
|
),
|
||||||
|
toDate: this.datetimeTransformer.toDate(
|
||||||
|
command.toDate,
|
||||||
|
{
|
||||||
|
date: command.fromDate,
|
||||||
|
time: command.schedule[0].time,
|
||||||
|
coordinates: {
|
||||||
|
lon: command.waypoints[0].lon,
|
||||||
|
lat: command.waypoints[0].lat,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
command.frequency,
|
||||||
|
),
|
||||||
|
schedule: command.schedule.map((scheduleItem: ScheduleItem) => ({
|
||||||
|
day: this.datetimeTransformer.day(
|
||||||
|
scheduleItem.day,
|
||||||
{
|
{
|
||||||
date: command.fromDate,
|
date: command.fromDate,
|
||||||
time: command.schedule[0].time,
|
time: scheduleItem.time,
|
||||||
coordinates: {
|
coordinates: {
|
||||||
lon: command.waypoints[0].lon,
|
lon: command.waypoints[0].lon,
|
||||||
lat: command.waypoints[0].lat,
|
lat: command.waypoints[0].lat,
|
||||||
|
@ -42,11 +64,10 @@ export class CreateAdService implements ICommandHandler {
|
||||||
},
|
},
|
||||||
command.frequency,
|
command.frequency,
|
||||||
),
|
),
|
||||||
toDate: this.datetimeTransformer.toDate(
|
time: this.datetimeTransformer.time(
|
||||||
command.toDate,
|
|
||||||
{
|
{
|
||||||
date: command.fromDate,
|
date: command.fromDate,
|
||||||
time: command.schedule[0].time,
|
time: scheduleItem.time,
|
||||||
coordinates: {
|
coordinates: {
|
||||||
lon: command.waypoints[0].lon,
|
lon: command.waypoints[0].lon,
|
||||||
lat: command.waypoints[0].lat,
|
lat: command.waypoints[0].lat,
|
||||||
|
@ -54,52 +75,27 @@ export class CreateAdService implements ICommandHandler {
|
||||||
},
|
},
|
||||||
command.frequency,
|
command.frequency,
|
||||||
),
|
),
|
||||||
schedule: command.schedule.map((scheduleItem: ScheduleItem) => ({
|
margin: scheduleItem.margin,
|
||||||
day: this.datetimeTransformer.day(
|
})),
|
||||||
scheduleItem.day,
|
seatsProposed: command.seatsProposed ?? 0,
|
||||||
{
|
seatsRequested: command.seatsRequested ?? 0,
|
||||||
date: command.fromDate,
|
strict: command.strict,
|
||||||
time: scheduleItem.time,
|
waypoints: command.waypoints.map((waypoint: Waypoint) => ({
|
||||||
coordinates: {
|
position: waypoint.position,
|
||||||
lon: command.waypoints[0].lon,
|
address: {
|
||||||
lat: command.waypoints[0].lat,
|
name: waypoint.name,
|
||||||
},
|
houseNumber: waypoint.houseNumber,
|
||||||
},
|
street: waypoint.street,
|
||||||
command.frequency,
|
postalCode: waypoint.postalCode,
|
||||||
),
|
locality: waypoint.locality,
|
||||||
time: this.datetimeTransformer.time(
|
country: waypoint.country,
|
||||||
{
|
coordinates: {
|
||||||
date: command.fromDate,
|
lon: waypoint.lon,
|
||||||
time: scheduleItem.time,
|
lat: waypoint.lat,
|
||||||
coordinates: {
|
|
||||||
lon: command.waypoints[0].lon,
|
|
||||||
lat: command.waypoints[0].lat,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
command.frequency,
|
|
||||||
),
|
|
||||||
margin: scheduleItem.margin,
|
|
||||||
})),
|
|
||||||
seatsProposed: command.seatsProposed ?? 0,
|
|
||||||
seatsRequested: command.seatsRequested ?? 0,
|
|
||||||
strict: command.strict,
|
|
||||||
waypoints: command.waypoints.map((waypoint: Waypoint) => ({
|
|
||||||
position: waypoint.position,
|
|
||||||
address: {
|
|
||||||
name: waypoint.name,
|
|
||||||
houseNumber: waypoint.houseNumber,
|
|
||||||
street: waypoint.street,
|
|
||||||
postalCode: waypoint.postalCode,
|
|
||||||
locality: waypoint.locality,
|
|
||||||
country: waypoint.country,
|
|
||||||
coordinates: {
|
|
||||||
lon: waypoint.lon,
|
|
||||||
lat: waypoint.lat,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})),
|
},
|
||||||
},
|
})),
|
||||||
);
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.repository.insert(ad);
|
await this.repository.insert(ad);
|
||||||
|
|
|
@ -8,9 +8,7 @@ import { WaypointProps } from './value-objects/waypoint.value-object';
|
||||||
export class AdEntity extends AggregateRoot<AdProps> {
|
export class AdEntity extends AggregateRoot<AdProps> {
|
||||||
protected readonly _id: AggregateID;
|
protected readonly _id: AggregateID;
|
||||||
|
|
||||||
static create = (
|
static create = (create: CreateAdProps): AdEntity => {
|
||||||
create: CreateAdProps
|
|
||||||
): AdEntity => {
|
|
||||||
const id = v4();
|
const id = v4();
|
||||||
const props: AdProps = { ...create };
|
const props: AdProps = { ...create };
|
||||||
const ad = new AdEntity({ id, props });
|
const ad = new AdEntity({ id, props });
|
||||||
|
|
|
@ -5,10 +5,7 @@ import {
|
||||||
GeoDateTime,
|
GeoDateTime,
|
||||||
} from '../core/application/ports/datetime-transformer.port';
|
} from '../core/application/ports/datetime-transformer.port';
|
||||||
import { TimeConverterPort } from '../core/application/ports/time-converter.port';
|
import { TimeConverterPort } from '../core/application/ports/time-converter.port';
|
||||||
import {
|
import { TIMEZONE_FINDER, TIME_CONVERTER } from '../ad.di-tokens';
|
||||||
TIMEZONE_FINDER,
|
|
||||||
TIME_CONVERTER,
|
|
||||||
} from '../ad.di-tokens';
|
|
||||||
import { TimezoneFinderPort } from '../core/application/ports/timezone-finder.port';
|
import { TimezoneFinderPort } from '../core/application/ports/timezone-finder.port';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -17,8 +14,7 @@ export class InputDateTimeTransformer implements DateTimeTransformerPort {
|
||||||
@Inject(TIMEZONE_FINDER)
|
@Inject(TIMEZONE_FINDER)
|
||||||
private readonly timezoneFinder: TimezoneFinderPort,
|
private readonly timezoneFinder: TimezoneFinderPort,
|
||||||
@Inject(TIME_CONVERTER) private readonly timeConverter: TimeConverterPort,
|
@Inject(TIME_CONVERTER) private readonly timeConverter: TimeConverterPort,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the fromDate : if an ad is punctual, the departure date
|
* Compute the fromDate : if an ad is punctual, the departure date
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
|
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
|
@ -4,8 +4,5 @@ import { TimezoneFinderPort } from '../core/application/ports/timezone-finder.po
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TimezoneFinder implements TimezoneFinderPort {
|
export class TimezoneFinder implements TimezoneFinderPort {
|
||||||
timezones = (
|
timezones = (lon: number, lat: number): string[] => find(lat, lon);
|
||||||
lon: number,
|
|
||||||
lat: number,
|
|
||||||
): string[] => find(lat, lon);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,16 +24,16 @@ export class CreateAdRequestDto {
|
||||||
|
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
@HasRole('passenger', {
|
@HasRole('passenger', {
|
||||||
message: 'At least one of driver or passenger property needs to be truthy'
|
message: 'At least one of driver or passenger property needs to be truthy',
|
||||||
})
|
})
|
||||||
@HasSeats('seatsProposed', {
|
@HasSeats('seatsProposed', {
|
||||||
message: 'Number of seats proposed as a driver is required'
|
message: 'Number of seats proposed as a driver is required',
|
||||||
})
|
})
|
||||||
driver: boolean;
|
driver: boolean;
|
||||||
|
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
@HasSeats('seatsRequested', {
|
@HasSeats('seatsRequested', {
|
||||||
message: 'Number of seats requested as a passenger is required'
|
message: 'Number of seats requested as a passenger is required',
|
||||||
})
|
})
|
||||||
passenger: boolean;
|
passenger: boolean;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { IsOptional, IsMilitaryTime, IsInt, Min, Max } from 'class-validator';
|
import { IsMilitaryTime, IsInt, Min, Max } from 'class-validator';
|
||||||
|
|
||||||
export class ScheduleItemDto {
|
export class ScheduleItemDto {
|
||||||
@IsInt()
|
@IsInt()
|
||||||
|
|
|
@ -19,7 +19,7 @@ export function HasRole(
|
||||||
validate(value: any, args: ValidationArguments) {
|
validate(value: any, args: ValidationArguments) {
|
||||||
const [relatedPropertyName] = args.constraints;
|
const [relatedPropertyName] = args.constraints;
|
||||||
const relatedValue = (args.object as any)[relatedPropertyName];
|
const relatedValue = (args.object as any)[relatedPropertyName];
|
||||||
return value || relatedValue;
|
return value || relatedValue;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ export function HasSeats(
|
||||||
validate(value: any, args: ValidationArguments) {
|
validate(value: any, args: ValidationArguments) {
|
||||||
const [relatedPropertyName] = args.constraints;
|
const [relatedPropertyName] = args.constraints;
|
||||||
const relatedValue = (args.object as any)[relatedPropertyName];
|
const relatedValue = (args.object as any)[relatedPropertyName];
|
||||||
return (value && relatedValue>0) || !value;
|
return (value && relatedValue > 0) || !value;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { IsInt, IsOptional } from 'class-validator';
|
import { IsInt } from 'class-validator';
|
||||||
import { AddressDto } from './address.dto';
|
import { AddressDto } from './address.dto';
|
||||||
|
|
||||||
export class WaypointDto extends AddressDto {
|
export class WaypointDto extends AddressDto {
|
||||||
|
|
|
@ -7,10 +7,7 @@ import {
|
||||||
} from '@modules/ad/ad.di-tokens';
|
} from '@modules/ad/ad.di-tokens';
|
||||||
import { AdMapper } from '@modules/ad/ad.mapper';
|
import { AdMapper } from '@modules/ad/ad.mapper';
|
||||||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||||
import {
|
import { CreateAdProps, Frequency } from '@modules/ad/core/domain/ad.types';
|
||||||
CreateAdProps,
|
|
||||||
Frequency,
|
|
||||||
} from '@modules/ad/core/domain/ad.types';
|
|
||||||
import { AdRepository } from '@modules/ad/infrastructure/ad.repository';
|
import { AdRepository } from '@modules/ad/infrastructure/ad.repository';
|
||||||
import { OutputDateTimeTransformer } from '@modules/ad/infrastructure/output-datetime-transformer';
|
import { OutputDateTimeTransformer } from '@modules/ad/infrastructure/output-datetime-transformer';
|
||||||
import { PrismaService } from '@modules/ad/infrastructure/prisma.service';
|
import { PrismaService } from '@modules/ad/infrastructure/prisma.service';
|
||||||
|
@ -230,9 +227,7 @@ describe('Ad Repository', () => {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const adToCreate: AdEntity = AdEntity.create(
|
const adToCreate: AdEntity = AdEntity.create(createAdProps);
|
||||||
createAdProps,
|
|
||||||
);
|
|
||||||
await adRepository.insert(adToCreate);
|
await adRepository.insert(adToCreate);
|
||||||
|
|
||||||
const afterCount = await prismaService.ad.count();
|
const afterCount = await prismaService.ad.count();
|
||||||
|
@ -308,9 +303,7 @@ describe('Ad Repository', () => {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const adToCreate: AdEntity = AdEntity.create(
|
const adToCreate: AdEntity = AdEntity.create(createAdProps);
|
||||||
createAdProps,
|
|
||||||
);
|
|
||||||
await adRepository.insert(adToCreate);
|
await adRepository.insert(adToCreate);
|
||||||
|
|
||||||
const afterCount = await prismaService.ad.count();
|
const afterCount = await prismaService.ad.count();
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||||
import {
|
import { CreateAdProps, Frequency } from '@modules/ad/core/domain/ad.types';
|
||||||
CreateAdProps,
|
|
||||||
Frequency,
|
|
||||||
} from '@modules/ad/core/domain/ad.types';
|
|
||||||
import { WaypointProps } from '@modules/ad/core/domain/value-objects/waypoint.value-object';
|
import { WaypointProps } from '@modules/ad/core/domain/value-objects/waypoint.value-object';
|
||||||
|
|
||||||
const originWaypointProps: WaypointProps = {
|
const originWaypointProps: WaypointProps = {
|
||||||
|
|
|
@ -102,9 +102,8 @@ describe('create-ad.service', () => {
|
||||||
AdEntity.create = jest.fn().mockReturnValue({
|
AdEntity.create = jest.fn().mockReturnValue({
|
||||||
id: '047a6ecf-23d4-4d3e-877c-3225d560a8da',
|
id: '047a6ecf-23d4-4d3e-877c-3225d560a8da',
|
||||||
});
|
});
|
||||||
const result: AggregateID = await createAdService.execute(
|
const result: AggregateID =
|
||||||
createAdCommand,
|
await createAdService.execute(createAdCommand);
|
||||||
);
|
|
||||||
expect(result).toBe('047a6ecf-23d4-4d3e-877c-3225d560a8da');
|
expect(result).toBe('047a6ecf-23d4-4d3e-877c-3225d560a8da');
|
||||||
});
|
});
|
||||||
it('should throw an error if something bad happens', async () => {
|
it('should throw an error if something bad happens', async () => {
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import { AD_REPOSITORY } from '@modules/ad/ad.di-tokens';
|
import { AD_REPOSITORY } from '@modules/ad/ad.di-tokens';
|
||||||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||||
import {
|
import { CreateAdProps, Frequency } from '@modules/ad/core/domain/ad.types';
|
||||||
CreateAdProps,
|
|
||||||
Frequency,
|
|
||||||
} from '@modules/ad/core/domain/ad.types';
|
|
||||||
import { FindAdByIdQuery } from '@modules/ad/core/application/queries/find-ad-by-id/find-ad-by-id.query';
|
import { FindAdByIdQuery } from '@modules/ad/core/application/queries/find-ad-by-id/find-ad-by-id.query';
|
||||||
import { FindAdByIdQueryHandler } from '@modules/ad/core/application/queries/find-ad-by-id/find-ad-by-id.query-handler';
|
import { FindAdByIdQueryHandler } from '@modules/ad/core/application/queries/find-ad-by-id/find-ad-by-id.query-handler';
|
||||||
import { WaypointProps } from '@modules/ad/core/domain/value-objects/waypoint.value-object';
|
import { WaypointProps } from '@modules/ad/core/domain/value-objects/waypoint.value-object';
|
||||||
|
@ -59,9 +56,7 @@ const punctualPassengerCreateAdProps: CreateAdProps = {
|
||||||
passenger: true,
|
passenger: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ad: AdEntity = AdEntity.create(
|
const ad: AdEntity = AdEntity.create(punctualPassengerCreateAdProps);
|
||||||
punctualPassengerCreateAdProps,
|
|
||||||
);
|
|
||||||
|
|
||||||
const mockAdRepository = {
|
const mockAdRepository = {
|
||||||
findOneById: jest.fn().mockImplementation(() => ad),
|
findOneById: jest.fn().mockImplementation(() => ad),
|
||||||
|
@ -95,9 +90,8 @@ describe('find-ad-by-id.query-handler', () => {
|
||||||
const findAdbyIdQuery = new FindAdByIdQuery(
|
const findAdbyIdQuery = new FindAdByIdQuery(
|
||||||
'dd264806-13b4-4226-9b18-87adf0ad5dd1',
|
'dd264806-13b4-4226-9b18-87adf0ad5dd1',
|
||||||
);
|
);
|
||||||
const ad: AdEntity = await findAdByIdQueryHandler.execute(
|
const ad: AdEntity =
|
||||||
findAdbyIdQuery,
|
await findAdByIdQueryHandler.execute(findAdbyIdQuery);
|
||||||
);
|
|
||||||
expect(ad.getProps().fromDate).toBe('2023-06-22');
|
expect(ad.getProps().fromDate).toBe('2023-06-22');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { TIMEZONE_FINDER, TIME_CONVERTER } from '@modules/ad/ad.di-tokens';
|
||||||
TIMEZONE_FINDER,
|
|
||||||
TIME_CONVERTER,
|
|
||||||
} from '@modules/ad/ad.di-tokens';
|
|
||||||
import { Frequency } from '@modules/ad/core/application/ports/datetime-transformer.port';
|
import { Frequency } from '@modules/ad/core/application/ports/datetime-transformer.port';
|
||||||
import { TimeConverterPort } from '@modules/ad/core/application/ports/time-converter.port';
|
import { TimeConverterPort } from '@modules/ad/core/application/ports/time-converter.port';
|
||||||
import { TimezoneFinderPort } from '@modules/ad/core/application/ports/timezone-finder.port';
|
import { TimezoneFinderPort } from '@modules/ad/core/application/ports/timezone-finder.port';
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { TIMEZONE_FINDER, TIME_CONVERTER } from '@modules/ad/ad.di-tokens';
|
||||||
TIMEZONE_FINDER,
|
|
||||||
TIME_CONVERTER,
|
|
||||||
} from '@modules/ad/ad.di-tokens';
|
|
||||||
import { Frequency } from '@modules/ad/core/application/ports/datetime-transformer.port';
|
import { Frequency } from '@modules/ad/core/application/ports/datetime-transformer.port';
|
||||||
import { TimeConverterPort } from '@modules/ad/core/application/ports/time-converter.port';
|
import { TimeConverterPort } from '@modules/ad/core/application/ports/time-converter.port';
|
||||||
import { TimezoneFinderPort } from '@modules/ad/core/application/ports/timezone-finder.port';
|
import { TimezoneFinderPort } from '@modules/ad/core/application/ports/timezone-finder.port';
|
||||||
|
|
|
@ -4,13 +4,13 @@ import { Validator } from 'class-validator';
|
||||||
describe('has seats decorator', () => {
|
describe('has seats decorator', () => {
|
||||||
class MyClass {
|
class MyClass {
|
||||||
@HasSeats('seatsProposed')
|
@HasSeats('seatsProposed')
|
||||||
driver:boolean;
|
driver: boolean;
|
||||||
@HasSeats('seatsRequested')
|
@HasSeats('seatsRequested')
|
||||||
passenger: boolean;
|
passenger: boolean;
|
||||||
|
|
||||||
seatsProposed?: number;
|
seatsProposed?: number;
|
||||||
seatsRequested?: number;
|
seatsRequested?: number;
|
||||||
}
|
}
|
||||||
it('should return a property decorator has a function', () => {
|
it('should return a property decorator has a function', () => {
|
||||||
const hasSeats = HasSeats('property');
|
const hasSeats = HasSeats('property');
|
||||||
expect(typeof hasSeats).toBe('function');
|
expect(typeof hasSeats).toBe('function');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { hasValidPositionIndexes } from "@modules/ad/interface/grpc-controllers/dtos/validators/has-valid-position-indexes.validator";
|
import { hasValidPositionIndexes } from '@modules/ad/interface/grpc-controllers/dtos/validators/has-valid-position-indexes.validator';
|
||||||
import { WaypointDto } from "@modules/ad/interface/grpc-controllers/dtos/waypoint.dto";
|
import { WaypointDto } from '@modules/ad/interface/grpc-controllers/dtos/waypoint.dto';
|
||||||
|
|
||||||
describe('addresses position validator', () => {
|
describe('addresses position validator', () => {
|
||||||
const waypoint1: WaypointDto = {
|
const waypoint1: WaypointDto = {
|
||||||
|
|
|
@ -3,7 +3,11 @@ import { MESSAGE_PUBLISHER } from './messager.di-tokens';
|
||||||
|
|
||||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||||
import { SERVICE_NAME } from '@src/app.constants';
|
import { SERVICE_NAME } from '@src/app.constants';
|
||||||
import { MessageBrokerModule, MessageBrokerModuleOptions, MessageBrokerPublisher } from '@mobicoop/message-broker-module';
|
import {
|
||||||
|
MessageBrokerModule,
|
||||||
|
MessageBrokerModuleOptions,
|
||||||
|
MessageBrokerPublisher,
|
||||||
|
} from '@mobicoop/message-broker-module';
|
||||||
|
|
||||||
const imports = [
|
const imports = [
|
||||||
MessageBrokerModule.forRootAsync({
|
MessageBrokerModule.forRootAsync({
|
||||||
|
@ -15,7 +19,9 @@ const imports = [
|
||||||
uri: configService.get<string>('MESSAGE_BROKER_URI') as string,
|
uri: configService.get<string>('MESSAGE_BROKER_URI') as string,
|
||||||
exchange: {
|
exchange: {
|
||||||
name: configService.get<string>('MESSAGE_BROKER_EXCHANGE') as string,
|
name: configService.get<string>('MESSAGE_BROKER_EXCHANGE') as string,
|
||||||
durable: configService.get<boolean>('MESSAGE_BROKER_EXCHANGE_DURABILITY') as boolean
|
durable: configService.get<boolean>(
|
||||||
|
'MESSAGE_BROKER_EXCHANGE_DURABILITY',
|
||||||
|
) as boolean,
|
||||||
},
|
},
|
||||||
name: SERVICE_NAME,
|
name: SERVICE_NAME,
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue