Trần Viết Sơn
Revert "Revert "Feature/update user""
8b6297d unverified
raw
history blame
735 Bytes
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<UserEntity | undefined> {
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);
}
}