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,
|
||||
"time": "07:00",
|
||||
"margin": 600,
|
||||
"margin": 600
|
||||
},
|
||||
{
|
||||
"day": 2,
|
||||
"time": "07:05",
|
||||
"margin": 600,
|
||||
"margin": 600
|
||||
},
|
||||
{
|
||||
"day": 5,
|
||||
"time": "07:10",
|
||||
"margin": 600,
|
||||
"margin": 600
|
||||
}
|
||||
],
|
||||
"waypoints": [
|
||||
|
|
|
@ -26,10 +26,14 @@ import { HEALTH_CRITICAL_LOGGING_KEY, SERVICE_NAME } from './app.constants';
|
|||
useFactory: async (
|
||||
configService: ConfigService,
|
||||
): Promise<ConfigurationModuleOptions> => ({
|
||||
domain: configService.get<string>('SERVICE_CONFIGURATION_DOMAIN') as string,
|
||||
domain: configService.get<string>(
|
||||
'SERVICE_CONFIGURATION_DOMAIN',
|
||||
) as string,
|
||||
messageBroker: {
|
||||
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: {
|
||||
host: configService.get<string>('REDIS_HOST') as string,
|
||||
|
|
|
@ -81,11 +81,6 @@ const adapters: Provider[] = [
|
|||
...orms,
|
||||
...adapters,
|
||||
],
|
||||
exports: [
|
||||
PrismaService,
|
||||
AdMapper,
|
||||
AD_REPOSITORY,
|
||||
TIMEZONE_FINDER,
|
||||
],
|
||||
exports: [PrismaService, AdMapper, AD_REPOSITORY, TIMEZONE_FINDER],
|
||||
})
|
||||
export class AdModule {}
|
||||
|
|
|
@ -15,18 +15,15 @@ import { DateTimeTransformerPort } from '../../ports/datetime-transformer.port';
|
|||
|
||||
@CommandHandler(CreateAdCommand)
|
||||
export class CreateAdService implements ICommandHandler {
|
||||
|
||||
constructor(
|
||||
@Inject(AD_REPOSITORY)
|
||||
private readonly repository: AdRepositoryPort,
|
||||
@Inject(INPUT_DATETIME_TRANSFORMER)
|
||||
private readonly datetimeTransformer: DateTimeTransformerPort,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
async execute(command: CreateAdCommand): Promise<AggregateID> {
|
||||
const ad = AdEntity.create(
|
||||
{
|
||||
const ad = AdEntity.create({
|
||||
userId: command.userId,
|
||||
driver: command.driver,
|
||||
passenger: command.passenger,
|
||||
|
@ -98,8 +95,7 @@ export class CreateAdService implements ICommandHandler {
|
|||
},
|
||||
},
|
||||
})),
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
try {
|
||||
await this.repository.insert(ad);
|
||||
|
|
|
@ -8,9 +8,7 @@ import { WaypointProps } from './value-objects/waypoint.value-object';
|
|||
export class AdEntity extends AggregateRoot<AdProps> {
|
||||
protected readonly _id: AggregateID;
|
||||
|
||||
static create = (
|
||||
create: CreateAdProps
|
||||
): AdEntity => {
|
||||
static create = (create: CreateAdProps): AdEntity => {
|
||||
const id = v4();
|
||||
const props: AdProps = { ...create };
|
||||
const ad = new AdEntity({ id, props });
|
||||
|
|
|
@ -5,10 +5,7 @@ import {
|
|||
GeoDateTime,
|
||||
} from '../core/application/ports/datetime-transformer.port';
|
||||
import { TimeConverterPort } from '../core/application/ports/time-converter.port';
|
||||
import {
|
||||
TIMEZONE_FINDER,
|
||||
TIME_CONVERTER,
|
||||
} from '../ad.di-tokens';
|
||||
import { TIMEZONE_FINDER, TIME_CONVERTER } from '../ad.di-tokens';
|
||||
import { TimezoneFinderPort } from '../core/application/ports/timezone-finder.port';
|
||||
|
||||
@Injectable()
|
||||
|
@ -17,8 +14,7 @@ export class InputDateTimeTransformer implements DateTimeTransformerPort {
|
|||
@Inject(TIMEZONE_FINDER)
|
||||
private readonly timezoneFinder: TimezoneFinderPort,
|
||||
@Inject(TIME_CONVERTER) private readonly timeConverter: TimeConverterPort,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 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';
|
||||
|
||||
@Injectable()
|
||||
|
|
|
@ -4,8 +4,5 @@ import { TimezoneFinderPort } from '../core/application/ports/timezone-finder.po
|
|||
|
||||
@Injectable()
|
||||
export class TimezoneFinder implements TimezoneFinderPort {
|
||||
timezones = (
|
||||
lon: number,
|
||||
lat: number,
|
||||
): string[] => find(lat, lon);
|
||||
timezones = (lon: number, lat: number): string[] => find(lat, lon);
|
||||
}
|
||||
|
|
|
@ -24,16 +24,16 @@ export class CreateAdRequestDto {
|
|||
|
||||
@IsBoolean()
|
||||
@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', {
|
||||
message: 'Number of seats proposed as a driver is required'
|
||||
message: 'Number of seats proposed as a driver is required',
|
||||
})
|
||||
driver: boolean;
|
||||
|
||||
@IsBoolean()
|
||||
@HasSeats('seatsRequested', {
|
||||
message: 'Number of seats requested as a passenger is required'
|
||||
message: 'Number of seats requested as a passenger is required',
|
||||
})
|
||||
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 {
|
||||
@IsInt()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IsInt, IsOptional } from 'class-validator';
|
||||
import { IsInt } from 'class-validator';
|
||||
import { AddressDto } from './address.dto';
|
||||
|
||||
export class WaypointDto extends AddressDto {
|
||||
|
|
|
@ -7,10 +7,7 @@ import {
|
|||
} from '@modules/ad/ad.di-tokens';
|
||||
import { AdMapper } from '@modules/ad/ad.mapper';
|
||||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||
import {
|
||||
CreateAdProps,
|
||||
Frequency,
|
||||
} from '@modules/ad/core/domain/ad.types';
|
||||
import { CreateAdProps, Frequency } from '@modules/ad/core/domain/ad.types';
|
||||
import { AdRepository } from '@modules/ad/infrastructure/ad.repository';
|
||||
import { OutputDateTimeTransformer } from '@modules/ad/infrastructure/output-datetime-transformer';
|
||||
import { PrismaService } from '@modules/ad/infrastructure/prisma.service';
|
||||
|
@ -230,9 +227,7 @@ describe('Ad Repository', () => {
|
|||
],
|
||||
};
|
||||
|
||||
const adToCreate: AdEntity = AdEntity.create(
|
||||
createAdProps,
|
||||
);
|
||||
const adToCreate: AdEntity = AdEntity.create(createAdProps);
|
||||
await adRepository.insert(adToCreate);
|
||||
|
||||
const afterCount = await prismaService.ad.count();
|
||||
|
@ -308,9 +303,7 @@ describe('Ad Repository', () => {
|
|||
],
|
||||
};
|
||||
|
||||
const adToCreate: AdEntity = AdEntity.create(
|
||||
createAdProps,
|
||||
);
|
||||
const adToCreate: AdEntity = AdEntity.create(createAdProps);
|
||||
await adRepository.insert(adToCreate);
|
||||
|
||||
const afterCount = await prismaService.ad.count();
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||
import {
|
||||
CreateAdProps,
|
||||
Frequency,
|
||||
} from '@modules/ad/core/domain/ad.types';
|
||||
import { CreateAdProps, Frequency } from '@modules/ad/core/domain/ad.types';
|
||||
import { WaypointProps } from '@modules/ad/core/domain/value-objects/waypoint.value-object';
|
||||
|
||||
const originWaypointProps: WaypointProps = {
|
||||
|
|
|
@ -102,9 +102,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 throw an error if something bad happens', async () => {
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import { AD_REPOSITORY } from '@modules/ad/ad.di-tokens';
|
||||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||
import {
|
||||
CreateAdProps,
|
||||
Frequency,
|
||||
} from '@modules/ad/core/domain/ad.types';
|
||||
import { 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 { 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';
|
||||
|
@ -59,9 +56,7 @@ const punctualPassengerCreateAdProps: CreateAdProps = {
|
|||
passenger: true,
|
||||
};
|
||||
|
||||
const ad: AdEntity = AdEntity.create(
|
||||
punctualPassengerCreateAdProps,
|
||||
);
|
||||
const ad: AdEntity = AdEntity.create(punctualPassengerCreateAdProps);
|
||||
|
||||
const mockAdRepository = {
|
||||
findOneById: jest.fn().mockImplementation(() => ad),
|
||||
|
@ -95,9 +90,8 @@ describe('find-ad-by-id.query-handler', () => {
|
|||
const findAdbyIdQuery = new FindAdByIdQuery(
|
||||
'dd264806-13b4-4226-9b18-87adf0ad5dd1',
|
||||
);
|
||||
const ad: AdEntity = await findAdByIdQueryHandler.execute(
|
||||
findAdbyIdQuery,
|
||||
);
|
||||
const ad: AdEntity =
|
||||
await findAdByIdQueryHandler.execute(findAdbyIdQuery);
|
||||
expect(ad.getProps().fromDate).toBe('2023-06-22');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import {
|
||||
TIMEZONE_FINDER,
|
||||
TIME_CONVERTER,
|
||||
} from '@modules/ad/ad.di-tokens';
|
||||
import { TIMEZONE_FINDER, TIME_CONVERTER } from '@modules/ad/ad.di-tokens';
|
||||
import { Frequency } from '@modules/ad/core/application/ports/datetime-transformer.port';
|
||||
import { TimeConverterPort } from '@modules/ad/core/application/ports/time-converter.port';
|
||||
import { TimezoneFinderPort } from '@modules/ad/core/application/ports/timezone-finder.port';
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import {
|
||||
TIMEZONE_FINDER,
|
||||
TIME_CONVERTER,
|
||||
} from '@modules/ad/ad.di-tokens';
|
||||
import { TIMEZONE_FINDER, TIME_CONVERTER } from '@modules/ad/ad.di-tokens';
|
||||
import { Frequency } from '@modules/ad/core/application/ports/datetime-transformer.port';
|
||||
import { TimeConverterPort } from '@modules/ad/core/application/ports/time-converter.port';
|
||||
import { TimezoneFinderPort } from '@modules/ad/core/application/ports/timezone-finder.port';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 { 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';
|
||||
|
||||
describe('addresses position validator', () => {
|
||||
const waypoint1: WaypointDto = {
|
||||
|
|
|
@ -3,7 +3,11 @@ import { MESSAGE_PUBLISHER } from './messager.di-tokens';
|
|||
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
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 = [
|
||||
MessageBrokerModule.forRootAsync({
|
||||
|
@ -15,7 +19,9 @@ const imports = [
|
|||
uri: configService.get<string>('MESSAGE_BROKER_URI') as string,
|
||||
exchange: {
|
||||
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,
|
||||
}),
|
||||
|
|
Loading…
Reference in New Issue