1- import { $NumberLike } from '@douglasneuroinformatics/libjs' ;
21import { CurrentUser } from '@douglasneuroinformatics/libnest' ;
32import type { RequestUser } from '@douglasneuroinformatics/libnest' ;
43import { Body , Controller , Get , HttpCode , HttpStatus , Post } from '@nestjs/common' ;
54import { ApiOperation } from '@nestjs/swagger' ;
6- import { Throttle } from '@nestjs/throttler' ;
75import { $LoginCredentials } from '@opendatacapture/schemas/auth' ;
8- import z from 'zod/v4' ;
96
107import { RouteAccess } from '@/core/decorators/route-access.decorator.js' ;
8+ import { ThrottleLoginRequest } from '@/core/decorators/throttle-login-request.decorator.js' ;
119
1210import { AuthService } from './auth.service.js' ;
1311
@@ -18,7 +16,7 @@ export class AuthController {
1816 @Get ( 'create-instrument-token' )
1917 @HttpCode ( HttpStatus . OK )
2018 @RouteAccess ( { action : 'create' , subject : 'Instrument' } )
21- @Throttle ( { long : { limit : 50 , ttl : 60_000 } } )
19+ @ThrottleLoginRequest ( )
2220 async getCreateInstrumentToken ( @CurrentUser ( ) currentUser : RequestUser ) : Promise < { accessToken : string } > {
2321 return this . authService . getCreateInstrumentToken ( currentUser ) ;
2422 }
@@ -27,12 +25,7 @@ export class AuthController {
2725 @HttpCode ( HttpStatus . OK )
2826 @Post ( 'login' )
2927 @RouteAccess ( 'public' )
30- @Throttle ( {
31- long : {
32- limit : $NumberLike . pipe ( z . number ( ) . int ( ) . positive ( ) ) . default ( 50 ) . parse ( process . env . LOGIN_REQUEST_THROTTLER_LIMIT ) ,
33- ttl : $NumberLike . pipe ( z . number ( ) . int ( ) . positive ( ) ) . default ( 60_000 ) . parse ( process . env . LOGIN_REQUEST_THROTTLER_TTL )
34- }
35- } )
28+ @ThrottleLoginRequest ( )
3629 async login ( @Body ( ) credentials : $LoginCredentials ) : Promise < { accessToken : string } > {
3730 return this . authService . login ( credentials ) ;
3831 }
0 commit comments