Spaces:
Sleeping
Sleeping
| 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'; | |
| ('Auth') | |
| ('auth') | |
| export class AuthController { | |
| constructor(private authService: AuthService) {} | |
| ('register') | |
| ({ summary: 'Register a new user' }) | |
| register(() dto: RegisterDto) { | |
| return this.authService.register(dto); | |
| } | |
| ('login') | |
| ({ summary: 'Login and get JWT' }) | |
| login(() dto: LoginDto) { | |
| return this.authService.login(dto); | |
| } | |
| ('me') | |
| () | |
| (AuthGuard('jwt')) | |
| ({ summary: 'Get current user profile' }) | |
| me(() req: any) { | |
| return req.user; | |
| } | |
| } | |