@@ -10,11 +10,19 @@ import {
10
10
Request ,
11
11
UseGuards ,
12
12
} from '@nestjs/common' ;
13
- import { ApiTags } from '@nestjs/swagger' ;
13
+ import {
14
+ ApiBadRequestResponse ,
15
+ ApiBearerAuth ,
16
+ ApiInternalServerErrorResponse ,
17
+ ApiOkResponse ,
18
+ ApiTags ,
19
+ ApiUnauthorizedResponse ,
20
+ } from '@nestjs/swagger' ;
14
21
15
22
import { UserGuard } from '@/guards/user.guard' ;
16
23
import { ServerResponse } from '../utils' ;
17
24
import { SessionsService } from './sessions.service' ;
25
+ import { LoginSessionDTO } from './dtos/LoginSessionDTO' ;
18
26
19
27
@ApiTags ( 'Sessões' )
20
28
@Controller ( 'sessions' )
@@ -23,14 +31,17 @@ export class SessionsController {
23
31
24
32
constructor ( private readonly sessionService : SessionsService ) { }
25
33
34
+ @ApiBadRequestResponse ( )
35
+ @ApiInternalServerErrorResponse ( )
36
+ @ApiOkResponse ( )
26
37
@Post ( '' )
27
38
async login (
28
- @Body ( ) body ,
39
+ @Body ( ) body : LoginSessionDTO ,
29
40
@Headers ( 'x-real-ip' ) ip : string ,
30
41
@Headers ( 'user-agent' ) userAgent : string ,
31
42
) {
32
43
try {
33
- const data = await this . sessionService . login ( { ... body , ip, userAgent } ) ;
44
+ const data = await this . sessionService . login ( body , ip , userAgent ) ;
34
45
return new ServerResponse ( 200 , 'Successfully logged in' , data ) ;
35
46
} catch ( err : any ) {
36
47
this . logger . error ( `Failed to login ${ err } ` ) ;
@@ -41,6 +52,10 @@ export class SessionsController {
41
52
}
42
53
}
43
54
55
+ @ApiBearerAuth ( )
56
+ @ApiUnauthorizedResponse ( )
57
+ @ApiInternalServerErrorResponse ( )
58
+ @ApiOkResponse ( )
44
59
@Get ( '' )
45
60
@UseGuards ( UserGuard )
46
61
async show ( @Request ( ) req ) {
@@ -54,6 +69,10 @@ export class SessionsController {
54
69
}
55
70
}
56
71
72
+ @ApiBearerAuth ( )
73
+ @ApiUnauthorizedResponse ( )
74
+ @ApiInternalServerErrorResponse ( )
75
+ @ApiOkResponse ( )
57
76
@Delete ( '' )
58
77
@UseGuards ( UserGuard )
59
78
async delete ( @Request ( ) req ) {
0 commit comments