From 1e4aa0eadc64f4abca4cd532adf377d5ef40fc64 Mon Sep 17 00:00:00 2001 From: sbriat Date: Tue, 11 Apr 2023 15:17:40 +0200 Subject: [PATCH] time request --- package.json | 1 + src/modules/matcher/domain/entities/time.ts | 8 +++----- src/modules/matcher/domain/entities/timing.ts | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 7df44c8..f8e276e 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ ".module.ts", ".request.ts", ".presenter.ts", + ".exception.ts", "main.ts" ], "rootDir": "src", diff --git a/src/modules/matcher/domain/entities/time.ts b/src/modules/matcher/domain/entities/time.ts index 63f8deb..ef4b0bf 100644 --- a/src/modules/matcher/domain/entities/time.ts +++ b/src/modules/matcher/domain/entities/time.ts @@ -1,11 +1,9 @@ import { MatcherException } from '../../exceptions/matcher.exception'; import { MarginDurations } from './margin-durations.type'; import { IRequestTime } from '../interfaces/time-request.interface'; -import { TimingDays, TimingFrequency } from './timing'; +import { TimingDays, TimingFrequency, Days } from './timing'; import { Schedule } from './schedule.type'; -const days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']; - export class Time { _timeRequest: IRequestTime; _defaultMarginDuration: number; @@ -84,7 +82,7 @@ export class Time { } if ( !Object.keys(this._timeRequest.schedule).some((elem) => - days.includes(elem), + Days.includes(elem), ) ) { throw new MatcherException(3, 'No valid day in the given schedule'); @@ -140,7 +138,7 @@ export class Time { if (this._timeRequest.marginDurations) { if ( !Object.keys(this._timeRequest.marginDurations).some((elem) => - days.includes(elem), + Days.includes(elem), ) ) { throw new MatcherException( diff --git a/src/modules/matcher/domain/entities/timing.ts b/src/modules/matcher/domain/entities/timing.ts index 87196af..567595a 100644 --- a/src/modules/matcher/domain/entities/timing.ts +++ b/src/modules/matcher/domain/entities/timing.ts @@ -12,3 +12,5 @@ export enum TimingDays { 'fri', 'sat', } + +export const Days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];