Created
September 26, 2022 14:41
-
-
Save hakimkal/cbebd6caeb1518862a6c501056953ee7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| Body, | |
| ClassSerializerInterceptor, | |
| Controller, | |
| Delete, | |
| Get, | |
| HttpStatus, | |
| Logger, | |
| Param, | |
| Post, | |
| Put, | |
| Res, | |
| UseGuards, | |
| UseInterceptors, | |
| } from '@nestjs/common'; | |
| import { FastifyReply } from 'fastify'; | |
| import { UsersService } from './users.service'; | |
| import { CreateUserDto } from './dto/create-user.dto'; | |
| import { UpdateUserDto } from './dto/update-user.dto'; | |
| import { SanaResponseDto } from '@/common/dto/sana.response.dto'; | |
| import { ApiTags } from '@nestjs/swagger'; | |
| import { JwtAuthGuard } from '@/users/auth/jwt.auth.guard'; | |
| @Controller('api/v1/users') | |
| @ApiTags('users') | |
| export class UsersController { | |
| logger = new Logger('Users'); | |
| constructor(private readonly usersService: UsersService) {} | |
| @Put(':id') | |
| @UseGuards(JwtAuthGuard) | |
| @UseInterceptors(ClassSerializerInterceptor) | |
| async update( | |
| @Param('id') id: string, | |
| @Body() updateUserDto: UpdateUserDto, | |
| @Res({ passthrough: true }) reply: FastifyReply, | |
| ) { | |
| const response = new SanaResponseDto(); | |
| response.data = await this.usersService.update(id, updateUserDto); | |
| reply.status(HttpStatus.OK); | |
| return response; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment