apps/recallassess/recallassess-api/src/api/client/profile/profile.controller.ts
api/client/profile
Methods |
|
| Async getProfile | ||||||
getProfile(auth: CLAuthData)
|
||||||
Decorators :
@Get()
|
||||||
|
Get current participant profile GET /api/client/profile
Parameters :
Returns :
Promise<ProfileDto>
|
| Async updateProfile | |||||||||
updateProfile(auth: CLAuthData, updateDto: UpdateProfileDto)
|
|||||||||
Decorators :
@Patch()
|
|||||||||
|
Update current participant profile PATCH /api/client/profile
Parameters :
Returns :
Promise<ProfileDto>
|
import { Body, Controller, Get, Patch, UsePipes, ValidationPipe } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { CLAuthData, ClientAuth } from '../../shared/decorators/client-auth.decorator';
import { ProfileDto, UpdateProfileDto } from './dto';
import { CLProfileService } from './profile.service';
@ApiTags('Client - Profile')
@Controller('api/client/profile')
export class CLProfileController {
constructor(private profileService: CLProfileService) {}
/**
* Get current participant profile
* GET /api/client/profile
*/
@Get()
@ApiOperation({ summary: 'Get current participant profile' })
@ApiResponse({
status: 200,
description: 'Returns current participant profile',
type: ProfileDto,
})
@ApiResponse({
status: 404,
description: 'Participant not found',
})
async getProfile(@ClientAuth() auth: CLAuthData): Promise<ProfileDto> {
return this.profileService.getProfile(auth.participantId);
}
/**
* Update current participant profile
* PATCH /api/client/profile
*/
@Patch()
@UsePipes(
new ValidationPipe({
transform: true,
whitelist: true,
forbidNonWhitelisted: true,
}),
)
@ApiOperation({ summary: 'Update current participant profile' })
@ApiResponse({
status: 200,
description: 'Returns updated participant profile',
type: ProfileDto,
})
@ApiResponse({
status: 404,
description: 'Participant not found',
})
async updateProfile(
@ClientAuth() auth: CLAuthData,
@Body() updateDto: UpdateProfileDto,
): Promise<ProfileDto> {
return this.profileService.updateProfile(auth.participantId, updateDto);
}
}