import { Body , Controller , HttpCode , HttpStatus , Post , UseGuards , } from '@nestjs/common' ; import { Public , GetCurrentUserId , GetCurrentUser } from '../common/decorators' ; import { RtGuard } from '../common/guards' ; import { AuthService } from './auth.service' ; import { AuthDto } from './dto' ; import { Tokens } from './types' ; @ Controller ( 'auth' ) export class AuthController { constructor ( private authService ) { } @ Public ( ) @ Post ( 'local/signup' ) @ HttpCode ( HttpStatus . CREATED ) signupLocal ( @ Body ( ) dto ) { return this . authService . signupLocal ( dto ) ; } @ Public ( ) @ Post ( 'local/signin' ) @ HttpCode ( HttpStatus . OK ) signinLocal ( @ Body ( ) dto ) { return this . authService . signinLocal ( dto ) ; } @ Post ( 'logout' ) @ HttpCode ( HttpStatus . OK ) logout ( @ GetCurrentUserId ( ) userId ) { return this . authService . logout ( userId ) ; } @ Public ( ) @ UseGuards ( RtGuard ) @ Post ( 'refresh' ) @ HttpCode ( HttpStatus . OK ) refreshTokens ( @ GetCurrentUserId ( ) userId , @ GetCurrentUser ( 'refreshToken' ) refreshToken ) { return this . authService . refreshTokens ( userId , refreshToken ) ; } }