implement SkRateLimiterService with Leaky Bucket rate limiting
This commit is contained in:
parent
f59af78d8a
commit
ffc2737478
9 changed files with 1102 additions and 26 deletions
27
packages/backend/src/core/TimeService.ts
Normal file
27
packages/backend/src/core/TimeService.ts
Normal file
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue