import { Body, Controller, Get, Param, Post, Request } from '@nestjs/common'; import { UserService } from './user.service.js'; import { UserEntity } from 'src/entities/user.entity.js'; import { UpdateUserDto } from './dto/update-user-dto.js'; @Controller('users') export class UsersController { constructor(private readonly usersService: UserService) {} @Get(':username') async getUser( @Param('username') username: string, ): Promise { return this.usersService.findOne(username); } @Post('updateUser') async updateUser(@Request() req){ const userId = req.user.sub; const updateUserDto = req.body; return this.usersService.updateUserById(userId, updateUserDto); } }