Skip to content

Commit 396c262

Browse files
committed
extract constants
1 parent 2f4afb7 commit 396c262

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

apps/api/src/core/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const DEFAULT_LOGIN_REQUEST_THROTTLER_LIMIT = 50;
2+
3+
export const DEFAULT_LOGIN_REQUEST_THROTTLER_TTL = 60_000;

apps/api/src/core/decorators/throttle-login-request.decorator.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ import { applyDecorators } from '@nestjs/common';
33
import { Throttle } from '@nestjs/throttler';
44
import z from 'zod/v4';
55

6+
import { DEFAULT_LOGIN_REQUEST_THROTTLER_LIMIT, DEFAULT_LOGIN_REQUEST_THROTTLER_TTL } from '../constants';
7+
68
// we cannot inject the config service here, so this needs to be parsed manually
79

810
const LOGIN_REQUEST_THROTTLER_LIMIT = $NumberLike
911
.pipe(z.number().int().positive())
10-
.default(50)
12+
.default(DEFAULT_LOGIN_REQUEST_THROTTLER_LIMIT)
1113
.parse(process.env.LOGIN_REQUEST_THROTTLER_LIMIT);
1214

1315
const LOGIN_REQUEST_THROTTLER_TTL = $NumberLike
1416
.pipe(z.number().int().positive())
15-
.default(60_000)
17+
.default(DEFAULT_LOGIN_REQUEST_THROTTLER_TTL)
1618
.parse(process.env.LOGIN_REQUEST_THROTTLER_TTL);
1719

1820
export function ThrottleLoginRequest() {

0 commit comments

Comments
 (0)