Spaces:
Runtime error
Runtime error
File size: 1,666 Bytes
405ccd5 d201b18 405ccd5 d201b18 405ccd5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import { Controller, Get, Put, Body, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { ProfileService } from './profile.service';
import { UpdateProfileDto } from './dto/update-profile.dto';
import { GetUser } from 'src/shared/decorators/get-user.decorator';
import { LogToDiscord } from 'src/shared/decorators/log-to-discord.decorator';
import type { UserSessionType } from 'src/shared/types/user-session.type';
import { UserAuthGuard } from '../auth/guards/user-auth.guard';
@ApiTags('User: Profile')
@Controller('user/profile')
@UseGuards(UserAuthGuard)
@ApiBearerAuth()
@LogToDiscord()
export class ProfileController {
constructor(private readonly profileService: ProfileService) {}
@Get()
@ApiOperation({ summary: 'Get user profile' })
async getProfile(@GetUser() sessionData: UserSessionType) {
const user = await this.profileService.getProfile(sessionData.user.id);
return { user };
}
@Put()
@ApiOperation({
summary: 'Update user profile (cannot change email or phone)',
})
async updateProfile(
@GetUser() sessionData: UserSessionType,
@Body() updateDto: UpdateProfileDto,
) {
const user = await this.profileService.updateProfile(
sessionData.user.id,
updateDto,
);
return {
message: 'Profile updated successfully',
user,
};
}
@Get('interests')
@ApiOperation({ summary: 'Get user interests (genres)' })
async getUserInterests(@GetUser() sessionData: UserSessionType) {
const interests = await this.profileService.getUserInterests(
sessionData.user.id,
);
return { interests };
}
}
|