diff options
| author | dakkar <dakkar@thenautilus.net> | 2024-12-08 20:49:07 +0000 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2024-12-08 20:49:07 +0000 |
| commit | 92ffd2a5fc7dc063d85f1a052e0ffff31b74fea9 (patch) | |
| tree | 79f0848608b35117cca373f2dcc26f6aba5dc894 /packages/backend/src/core/TimeService.ts | |
| parent | merge: Data driven about page sections (and add me as a contributor!) (!800) (diff) | |
| parent | fix type errors from new rate limit definitions (diff) | |
| download | sharkey-92ffd2a5fc7dc063d85f1a052e0ffff31b74fea9.tar.gz sharkey-92ffd2a5fc7dc063d85f1a052e0ffff31b74fea9.tar.bz2 sharkey-92ffd2a5fc7dc063d85f1a052e0ffff31b74fea9.zip | |
merge: Implement new SkRateLimiterServer with Leaky Bucket rate limits (resolves #592) (!799)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/799
Closes #592
Approved-by: dakkar <dakkar@thenautilus.net>
Approved-by: Marie <github@yuugi.dev>
Diffstat (limited to 'packages/backend/src/core/TimeService.ts')
| -rw-r--r-- | packages/backend/src/core/TimeService.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/backend/src/core/TimeService.ts b/packages/backend/src/core/TimeService.ts new file mode 100644 index 0000000000..59c3d4c12b --- /dev/null +++ b/packages/backend/src/core/TimeService.ts @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { Injectable } from '@nestjs/common'; + +/** + * Provides abstractions to access the current time. + * Exists for unit testing purposes, so that tests can "simulate" any given time for consistency. + */ +@Injectable() +export class TimeService { + /** + * Returns Date.now() + */ + public get now() { + return Date.now(); + } + + /** + * Returns a new Date instance. + */ + public get date() { + return new Date(); + } +} |