Skip to content

Commit 3f11983

Browse files
committed
extra checks + clean code
1 parent e4977be commit 3f11983

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/utils/time.utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export class TimeUtils {
2+
static readonly TIMESTAMP_IN_SECONDS_THRESHOLD = 100_000_000_000;
23
static isTimestampInSeconds(input: number): boolean {
3-
return input < 100_000_000_000;
4+
return input < TimeUtils.TIMESTAMP_IN_SECONDS_THRESHOLD;
45
}
56
}

src/utils/timestamp.parse.pipe.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export class TimestampParsePipe implements PipeTransform {
1616
throw new BadRequestException('Timestamp must be a number');
1717
}
1818

19+
if (valNumber <= 0) {
20+
throw new BadRequestException('Timestamp must be a positive number');
21+
}
22+
1923
const normalizedInputMs = TimeUtils.isTimestampInSeconds(valNumber) ? valNumber * 1000 : valNumber;
2024

2125
const supernovaActivationTimestampMs = this.apiConfigService.getSupernovaActivationTimestamp() * 1000;

0 commit comments

Comments
 (0)