| 1 | import { Body, Controller, Get, Headers, Post } from '@nestjs/common'; |
| 2 | import { AuthService } from './auth.service'; |
| 3 | import { LoginDto, RegisterDto } from '@app/common'; |
| 4 | import { SkipThrottle, Throttle } from '@nestjs/throttler'; |
| 5 | |
| 6 | @Controller('auth') |
| 7 | export class AuthController { |
| 8 | constructor(private readonly authService: AuthService) {} |
| 9 | |
| 10 | @Post('register') |
| 11 | @Throttle({ default: { limit: 3, ttl: 60000 } }) |
| 12 | register(@Body() registerDto: RegisterDto) { |
| 13 | return this.authService.register(registerDto); |
| 14 | } |
| 15 | |
| 16 | @Post('login') |
| 17 | @Throttle({ default: { limit: 5, ttl: 60000 } }) |
| 18 | login(@Body() loginDto: LoginDto) { |
| 19 | return this.authService.login(loginDto); |
| 20 | } |
| 21 | |
| 22 | @Get('profile') |
| 23 | @SkipThrottle() |
| 24 | getProfile(@Headers('authorization') authorization: string) { |
| 25 | return this.authService.getProfile(authorization); |
| 26 | } |
| 27 | } |