import { Controller, Post, Body, Get, UseGuards, Request } from '@nestjs/common'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger'; import { AuthGuard } from '@nestjs/passport'; import { AuthService } from './auth.service'; import { RegisterDto } from './dto/register.dto'; import { LoginDto } from './dto/login.dto'; @ApiTags('Auth') @Controller('auth') export class AuthController { constructor(private authService: AuthService) {} @Post('register') @ApiOperation({ summary: 'Register a new user' }) register(@Body() dto: RegisterDto) { return this.authService.register(dto); } @Post('login') @ApiOperation({ summary: 'Login and get JWT' }) login(@Body() dto: LoginDto) { return this.authService.login(dto); } @Get('me') @ApiBearerAuth() @UseGuards(AuthGuard('jwt')) @ApiOperation({ summary: 'Get current user profile' }) me(@Request() req: any) { return req.user; } }