Spaces:
Running
Running
| import { | |
| Controller, | |
| Post, | |
| Body, | |
| Get, | |
| UseGuards, | |
| Request, | |
| } from '@nestjs/common'; | |
| import { AuthService } from './auth.service'; | |
| import { RegisterDto } from './dto/register.dto'; | |
| import { LoginDto } from './dto/login.dto'; | |
| import { JwtAuthGuard } from './guards/jwt-auth.guard'; | |
| ('api/auth') | |
| export class AuthController { | |
| constructor(private readonly authService: AuthService) {} | |
| ('register') | |
| async register(() registerDto: RegisterDto) { | |
| const data = await this.authService.register(registerDto); | |
| return { success: true, data }; | |
| } | |
| ('login') | |
| async login(() loginDto: LoginDto) { | |
| const data = await this.authService.login(loginDto); | |
| return { success: true, data }; | |
| } | |
| (JwtAuthGuard) | |
| ('profile') | |
| async getProfile(() req) { | |
| const data = await this.authService.getProfile(req.user.userId); | |
| return { success: true, data }; | |
| } | |
| } | |