import { Controller, Get, Body, Patch, UseGuards } from "@nestjs/common"; import { ApiBearerAuth, ApiBody, ApiTags } from "@nestjs/swagger"; import { GlobalGuard } from "src/auth/guards/global.guard"; import { CurrentUser } from "src/decorators/user.decorator"; import { Roles } from "src/decorators/roles.decorator"; import { UpdateUserProfileDtoRq } from "./dto/user/update-profile.dto"; import { ProfileService } from "./profile.service"; @Controller("user/profile") @ApiTags("user") @ApiBearerAuth() @Roles() export class ProfileController { constructor(private readonly profileService: ProfileService) {} @Get() @UseGuards(GlobalGuard) async getProfile(@CurrentUser() user) { return await this.profileService.getProfileDetail(user.username, user.sub); } @Patch() @UseGuards(GlobalGuard) @ApiBody({ type: UpdateUserProfileDtoRq }) async updateProfile( @CurrentUser() user, @Body() body: UpdateUserProfileDtoRq, ) { return await this.profileService.updateProfile( user.username, body as Record, user.sub, ); } }