File

apps/api/src/user/profile.controller.ts

Prefix

profile

Index

Methods

Methods

get
get(id: number)
Decorators :
@Get(':id')
Parameters :
Name Type Optional
id number No
update
update(id: number, updatesUser: UserUpdate)
Decorators :
@Put(':id')
Parameters :
Name Type Optional
id number No
updatesUser UserUpdate No
import {
  Controller,
  UseGuards,
  Get,
  UseInterceptors,
  ClassSerializerInterceptor,
  Param,
  ParseIntPipe,
  Put,
  Body
} from '@nestjs/common'

import { UserService } from './user.service'
import { UserUpdate } from './dto/user-update.dto'
import { JWTAuthGuard } from '../auth/guards/jwt-auth.guard'
import { SessionAuthGuard } from '../auth/guards/session-auth.guard'
import { UserEntity } from '../entities/user.entity'
import { Jwt2faAuthGuard } from '../auth/guards/jwt-2fa-auth.guard'

@Controller('profile')
@UseGuards(Jwt2faAuthGuard, SessionAuthGuard)
@UseInterceptors(ClassSerializerInterceptor)
export class ProfileController {
  constructor(private readonly userService: UserService) {}

  @Get(':id')
  get(@Param('id', new ParseIntPipe()) id: number): Promise<UserEntity> {
    return this.userService.findOne({ where: { id } })
  }

  @Put(':id')
  update(
    @Param('id', new ParseIntPipe()) id: number,
    @Body() updatesUser: UserUpdate
  ): Promise<UserEntity> {
    return this.userService.update(id, updatesUser)
  }
}

results matching ""

    No results matching ""