Skip to content

Instantly share code, notes, and snippets.

@hakimkal
Created September 26, 2022 14:41
Show Gist options
  • Select an option

  • Save hakimkal/cbebd6caeb1518862a6c501056953ee7 to your computer and use it in GitHub Desktop.

Select an option

Save hakimkal/cbebd6caeb1518862a6c501056953ee7 to your computer and use it in GitHub Desktop.
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