apps/api/src/user/profile.controller.ts
profile
Methods |
get | ||||||
get(id: number)
|
||||||
Decorators :
@Get(':id')
|
||||||
Defined in apps/api/src/user/profile.controller.ts:27
|
||||||
Parameters :
Returns :
Promise<UserEntity>
|
update | |||||||||
update(id: number, updatesUser: UserUpdate)
|
|||||||||
Decorators :
@Put(':id')
|
|||||||||
Defined in apps/api/src/user/profile.controller.ts:32
|
|||||||||
Parameters :
Returns :
Promise<UserEntity>
|
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)
}
}