File size: 735 Bytes
8b6297d
13dd365
 
8b6297d
c114c72
 
9a12f24
 
c114c72
9a12f24
13dd365
 
 
9a12f24
c114c72
8b6297d
 
 
 
 
 
 
c114c72
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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);
  }
}