From 8d1d0f82cfefbc16177a436b3f9ce8d0f8516eb5 Mon Sep 17 00:00:00 2001 From: sbriat Date: Tue, 27 Jun 2023 14:49:08 +0200 Subject: [PATCH] refactor --- src/modules/ad/ad.mapper.ts | 8 +++--- .../commands/create-ad/create-ad.service.ts | 28 +++++++++---------- .../infrastructure/default-params-provider.ts | 28 +++++++++---------- .../health.http.controller.ts | 2 +- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/modules/ad/ad.mapper.ts b/src/modules/ad/ad.mapper.ts index aa21320..61f75d4 100644 --- a/src/modules/ad/ad.mapper.ts +++ b/src/modules/ad/ad.mapper.ts @@ -31,7 +31,7 @@ import { TimeConverterPort } from './core/ports/time-converter.port'; export class AdMapper implements Mapper { - private readonly defaultParams: DefaultParams; + private readonly _defaultParams: DefaultParams; constructor( @Inject(PARAMS_PROVIDER) @@ -41,7 +41,7 @@ export class AdMapper @Inject(TIME_CONVERTER) private readonly timeConverter: TimeConverterPort, ) { - this.defaultParams = defaultParamsProvider.getParams(); + this._defaultParams = defaultParamsProvider.getParams(); } toPersistence = (entity: AdEntity): AdWriteModel => { @@ -50,7 +50,7 @@ export class AdMapper const timezone = this.timezoneFinder.timezones( lon, lat, - this.defaultParams.DEFAULT_TIMEZONE, + this._defaultParams.DEFAULT_TIMEZONE, )[0]; const now = new Date(); const record: AdWriteModel = { @@ -146,7 +146,7 @@ export class AdMapper const timezone = this.timezoneFinder.timezones( record.waypoints[0].lon, record.waypoints[0].lat, - this.defaultParams.DEFAULT_TIMEZONE, + this._defaultParams.DEFAULT_TIMEZONE, )[0]; const entity = new AdEntity({ id: record.uuid, diff --git a/src/modules/ad/core/commands/create-ad/create-ad.service.ts b/src/modules/ad/core/commands/create-ad/create-ad.service.ts index b85affe..1fc16fc 100644 --- a/src/modules/ad/core/commands/create-ad/create-ad.service.ts +++ b/src/modules/ad/core/commands/create-ad/create-ad.service.ts @@ -13,7 +13,7 @@ import { Waypoint } from '../../types/waypoint'; @CommandHandler(CreateAdCommand) export class CreateAdService implements ICommandHandler { - private readonly defaultParams: DefaultParams; + private readonly _defaultParams: DefaultParams; constructor( @Inject(AD_REPOSITORY) @@ -21,7 +21,7 @@ export class CreateAdService implements ICommandHandler { @Inject(PARAMS_PROVIDER) private readonly defaultParamsProvider: DefaultParamsProviderPort, ) { - this.defaultParams = defaultParamsProvider.getParams(); + this._defaultParams = defaultParamsProvider.getParams(); } async execute(command: CreateAdCommand): Promise { @@ -55,20 +55,20 @@ export class CreateAdService implements ICommandHandler { })), }, { - driver: this.defaultParams.DRIVER, - passenger: this.defaultParams.PASSENGER, + driver: this._defaultParams.DRIVER, + passenger: this._defaultParams.PASSENGER, marginDurations: { - mon: this.defaultParams.MON_MARGIN, - tue: this.defaultParams.TUE_MARGIN, - wed: this.defaultParams.WED_MARGIN, - thu: this.defaultParams.THU_MARGIN, - fri: this.defaultParams.FRI_MARGIN, - sat: this.defaultParams.SAT_MARGIN, - sun: this.defaultParams.SUN_MARGIN, + mon: this._defaultParams.MON_MARGIN, + tue: this._defaultParams.TUE_MARGIN, + wed: this._defaultParams.WED_MARGIN, + thu: this._defaultParams.THU_MARGIN, + fri: this._defaultParams.FRI_MARGIN, + sat: this._defaultParams.SAT_MARGIN, + sun: this._defaultParams.SUN_MARGIN, }, - strict: this.defaultParams.STRICT, - seatsProposed: this.defaultParams.SEATS_PROPOSED, - seatsRequested: this.defaultParams.SEATS_REQUESTED, + strict: this._defaultParams.STRICT, + seatsProposed: this._defaultParams.SEATS_PROPOSED, + seatsRequested: this._defaultParams.SEATS_REQUESTED, }, ); diff --git a/src/modules/ad/infrastructure/default-params-provider.ts b/src/modules/ad/infrastructure/default-params-provider.ts index 3e1ee57..c27f5c1 100644 --- a/src/modules/ad/infrastructure/default-params-provider.ts +++ b/src/modules/ad/infrastructure/default-params-provider.ts @@ -5,20 +5,20 @@ import { DefaultParams } from '../core/ports/default-params.type'; @Injectable() export class DefaultParamsProvider implements DefaultParamsProviderPort { - constructor(private readonly configService: ConfigService) {} + constructor(private readonly _configService: ConfigService) {} getParams = (): DefaultParams => ({ - MON_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), - TUE_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), - WED_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), - THU_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), - FRI_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), - SAT_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), - SUN_MARGIN: parseInt(this.configService.get('DEPARTURE_MARGIN')), - DRIVER: this.configService.get('ROLE') == 'driver', - SEATS_PROPOSED: parseInt(this.configService.get('SEATS_PROPOSED')), - PASSENGER: this.configService.get('ROLE') == 'passenger', - SEATS_REQUESTED: parseInt(this.configService.get('SEATS_REQUESTED')), - STRICT: this.configService.get('STRICT_FREQUENCY') == 'true', - DEFAULT_TIMEZONE: this.configService.get('DEFAULT_TIMEZONE'), + MON_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')), + TUE_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')), + WED_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')), + THU_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')), + FRI_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')), + SAT_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')), + SUN_MARGIN: parseInt(this._configService.get('DEPARTURE_MARGIN')), + DRIVER: this._configService.get('ROLE') == 'driver', + SEATS_PROPOSED: parseInt(this._configService.get('SEATS_PROPOSED')), + PASSENGER: this._configService.get('ROLE') == 'passenger', + SEATS_REQUESTED: parseInt(this._configService.get('SEATS_REQUESTED')), + STRICT: this._configService.get('STRICT_FREQUENCY') == 'true', + DEFAULT_TIMEZONE: this._configService.get('DEFAULT_TIMEZONE'), }); } diff --git a/src/modules/health/interface/http-controllers/health.http.controller.ts b/src/modules/health/interface/http-controllers/health.http.controller.ts index fbc9e87..256dae5 100644 --- a/src/modules/health/interface/http-controllers/health.http.controller.ts +++ b/src/modules/health/interface/http-controllers/health.http.controller.ts @@ -10,7 +10,7 @@ import { export class HealthHttpController { constructor( private readonly repositoriesHealthIndicatorUseCase: RepositoriesHealthIndicatorUseCase, - private healthCheckService: HealthCheckService, + private readonly healthCheckService: HealthCheckService, ) {} @Get()