refactor: apply review suggestions
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
+4
-4
@@ -65,17 +65,17 @@ export function createCredentialsBarrier(options: {
|
||||
const unauthenticatedPredicates = new Array<(path: string) => boolean>();
|
||||
const cookiePredicates = new Array<(path: string) => boolean>();
|
||||
|
||||
// Default rate limit is 100 requests per 15 minutes
|
||||
// Default rate limit is 60 requests per 1 minute
|
||||
const max = config?.has('backend.auth.rateLimit.max')
|
||||
? config.getNumber('backend.auth.rateLimit.max')
|
||||
: 100;
|
||||
: 60;
|
||||
|
||||
const duration = config?.has('backend.auth.rateLimit.window')
|
||||
? readDurationFromConfig(config.getConfig('backend.auth.rateLimit.window'))
|
||||
: undefined;
|
||||
|
||||
// Default rate limit window is 15 minutes
|
||||
const windowMs = duration ? durationToMilliseconds(duration) : 15 * 60 * 1000;
|
||||
// Default rate limit window is 1 minute
|
||||
const windowMs = duration ? durationToMilliseconds(duration) : 1 * 60 * 1000;
|
||||
|
||||
const limiter = rateLimit({
|
||||
windowMs,
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ describe('RateLimitStore', () => {
|
||||
});
|
||||
|
||||
it('should initialize with default options', () => {
|
||||
expect(rateLimitStore.windowMs).toBe(15 * 60 * 1000);
|
||||
expect(rateLimitStore.windowMs).toBe(1 * 60 * 1000);
|
||||
});
|
||||
|
||||
it('should initialize with custom options', () => {
|
||||
|
||||
@@ -44,9 +44,9 @@ type CacheStoreValue = {
|
||||
export class RateLimitStore implements Store {
|
||||
/**
|
||||
* The duration of time before which all hit counts are reset (in milliseconds).
|
||||
* default: 15 minutes
|
||||
* default: 60 requests per minute
|
||||
*/
|
||||
windowMs: number = 15 * 60 * 1000;
|
||||
windowMs: number = 1 * 60 * 1000;
|
||||
prefix: string;
|
||||
#cache: CacheService;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user