This commit is contained in:
sbriat 2023-06-27 14:49:08 +02:00
parent 2c6e045841
commit 8d1d0f82cf
4 changed files with 33 additions and 33 deletions

View File

@ -31,7 +31,7 @@ import { TimeConverterPort } from './core/ports/time-converter.port';
export class AdMapper export class AdMapper
implements Mapper<AdEntity, AdReadModel, AdWriteModel, AdResponseDto> implements Mapper<AdEntity, AdReadModel, AdWriteModel, AdResponseDto>
{ {
private readonly defaultParams: DefaultParams; private readonly _defaultParams: DefaultParams;
constructor( constructor(
@Inject(PARAMS_PROVIDER) @Inject(PARAMS_PROVIDER)
@ -41,7 +41,7 @@ export class AdMapper
@Inject(TIME_CONVERTER) @Inject(TIME_CONVERTER)
private readonly timeConverter: TimeConverterPort, private readonly timeConverter: TimeConverterPort,
) { ) {
this.defaultParams = defaultParamsProvider.getParams(); this._defaultParams = defaultParamsProvider.getParams();
} }
toPersistence = (entity: AdEntity): AdWriteModel => { toPersistence = (entity: AdEntity): AdWriteModel => {
@ -50,7 +50,7 @@ export class AdMapper
const timezone = this.timezoneFinder.timezones( const timezone = this.timezoneFinder.timezones(
lon, lon,
lat, lat,
this.defaultParams.DEFAULT_TIMEZONE, this._defaultParams.DEFAULT_TIMEZONE,
)[0]; )[0];
const now = new Date(); const now = new Date();
const record: AdWriteModel = { const record: AdWriteModel = {
@ -146,7 +146,7 @@ export class AdMapper
const timezone = this.timezoneFinder.timezones( const timezone = this.timezoneFinder.timezones(
record.waypoints[0].lon, record.waypoints[0].lon,
record.waypoints[0].lat, record.waypoints[0].lat,
this.defaultParams.DEFAULT_TIMEZONE, this._defaultParams.DEFAULT_TIMEZONE,
)[0]; )[0];
const entity = new AdEntity({ const entity = new AdEntity({
id: record.uuid, id: record.uuid,

View File

@ -13,7 +13,7 @@ import { Waypoint } from '../../types/waypoint';
@CommandHandler(CreateAdCommand) @CommandHandler(CreateAdCommand)
export class CreateAdService implements ICommandHandler { export class CreateAdService implements ICommandHandler {
private readonly defaultParams: DefaultParams; private readonly _defaultParams: DefaultParams;
constructor( constructor(
@Inject(AD_REPOSITORY) @Inject(AD_REPOSITORY)
@ -21,7 +21,7 @@ export class CreateAdService implements ICommandHandler {
@Inject(PARAMS_PROVIDER) @Inject(PARAMS_PROVIDER)
private readonly defaultParamsProvider: DefaultParamsProviderPort, private readonly defaultParamsProvider: DefaultParamsProviderPort,
) { ) {
this.defaultParams = defaultParamsProvider.getParams(); this._defaultParams = defaultParamsProvider.getParams();
} }
async execute(command: CreateAdCommand): Promise<AggregateID> { async execute(command: CreateAdCommand): Promise<AggregateID> {
@ -55,20 +55,20 @@ export class CreateAdService implements ICommandHandler {
})), })),
}, },
{ {
driver: this.defaultParams.DRIVER, driver: this._defaultParams.DRIVER,
passenger: this.defaultParams.PASSENGER, passenger: this._defaultParams.PASSENGER,
marginDurations: { marginDurations: {
mon: this.defaultParams.MON_MARGIN, mon: this._defaultParams.MON_MARGIN,
tue: this.defaultParams.TUE_MARGIN, tue: this._defaultParams.TUE_MARGIN,
wed: this.defaultParams.WED_MARGIN, wed: this._defaultParams.WED_MARGIN,
thu: this.defaultParams.THU_MARGIN, thu: this._defaultParams.THU_MARGIN,
fri: this.defaultParams.FRI_MARGIN, fri: this._defaultParams.FRI_MARGIN,
sat: this.defaultParams.SAT_MARGIN, sat: this._defaultParams.SAT_MARGIN,
sun: this.defaultParams.SUN_MARGIN, sun: this._defaultParams.SUN_MARGIN,
}, },
strict: this.defaultParams.STRICT, strict: this._defaultParams.STRICT,
seatsProposed: this.defaultParams.SEATS_PROPOSED, seatsProposed: this._defaultParams.SEATS_PROPOSED,
seatsRequested: this.defaultParams.SEATS_REQUESTED, seatsRequested: this._defaultParams.SEATS_REQUESTED,
}, },
); );

View File

@ -5,20 +5,20 @@ import { DefaultParams } from '../core/ports/default-params.type';
@Injectable() @Injectable()
export class DefaultParamsProvider implements DefaultParamsProviderPort { export class DefaultParamsProvider implements DefaultParamsProviderPort {
constructor(private readonly configService: ConfigService) {} constructor(private readonly _configService: ConfigService) {}
getParams = (): DefaultParams => ({ getParams = (): DefaultParams => ({
MON_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), MON_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')),
TUE_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), TUE_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')),
WED_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), WED_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')),
THU_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), THU_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')),
FRI_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), FRI_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')),
SAT_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), SAT_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')),
SUN_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), SUN_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')),
DRIVER: this.configService.get('ROLE') == 'driver', DRIVER: this._configService.get('ROLE') == 'driver',
SEATS_PROPOSED: parseInt(this.configService.get('SEATS_PROPOSED')), SEATS_PROPOSED: parseInt(this._configService.get('SEATS_PROPOSED')),
PASSENGER: this.configService.get('ROLE') == 'passenger', PASSENGER: this._configService.get('ROLE') == 'passenger',
SEATS_REQUESTED: parseInt(this.configService.get('SEATS_REQUESTED')), SEATS_REQUESTED: parseInt(this._configService.get('SEATS_REQUESTED')),
STRICT: this.configService.get('STRICT_FREQUENCY') == 'true', STRICT: this._configService.get('STRICT_FREQUENCY') == 'true',
DEFAULT_TIMEZONE: this.configService.get('DEFAULT_TIMEZONE'), DEFAULT_TIMEZONE: this._configService.get('DEFAULT_TIMEZONE'),
}); });
} }

View File

@ -10,7 +10,7 @@ import {
export class HealthHttpController { export class HealthHttpController {
constructor( constructor(
private readonly repositoriesHealthIndicatorUseCase: RepositoriesHealthIndicatorUseCase, private readonly repositoriesHealthIndicatorUseCase: RepositoriesHealthIndicatorUseCase,
private healthCheckService: HealthCheckService, private readonly healthCheckService: HealthCheckService,
) {} ) {}
@Get() @Get()