import { Controller, Get, Patch, Post, Delete, Param, Body, UseGuards, Req, } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; import { UsersService } from './users.service'; import { JwtAuthGuard } from '../auth/jwt-auth.guard'; @ApiTags('Users & Profiles') @Controller('users') export class UsersController { constructor(private readonly usersService: UsersService) {} @Get('me') @UseGuards(JwtAuthGuard) @ApiBearerAuth() @ApiOperation({ summary: 'Get logged-in user profile' }) getMe(@Req() req: any) { return this.usersService.getPublicProfile(req.user.userId); } @Patch('me') @UseGuards(JwtAuthGuard) @ApiBearerAuth() @ApiOperation({ summary: 'Update logged-in user profile' }) updateMe( @Req() req: any, @Body() dto: { display_name?: string; username?: string; bio?: string; country?: string; }, ) { return this.usersService.updateProfile(req.user.userId, dto); } @Post('me/avatar') @UseGuards(JwtAuthGuard) @ApiBearerAuth() @ApiOperation({ summary: 'Upload/replace profile picture' }) uploadAvatar(@Req() req: any, @Body() dto: { avatar_url: string }) { return this.usersService.uploadAvatar(req.user.userId, dto.avatar_url); } @Delete('me') @UseGuards(JwtAuthGuard) @ApiBearerAuth() @ApiOperation({ summary: 'Soft-delete/deactivate account' }) deleteMe(@Req() req: any) { return this.usersService.deleteAccount(req.user.userId); } @Get(':id') @ApiOperation({ summary: 'Get public user profile' }) getPublicProfile(@Param('id') id: string) { return this.usersService.getPublicProfile(id); } @Get(':id/playlists') @ApiOperation({ summary: 'List a user public playlists' }) getUserPlaylists(@Param('id') id: string) { return [ { id: 'playlist-001', title: 'Kannada Hits & Melodies 2026', is_public: true, owner_id: id, }, ]; } @Get(':id/followers') @ApiOperation({ summary: 'List followers of a user' }) getUserFollowers(@Param('id') id: string) { return [ { id: 'user-002', username: 'music_lover', display_name: 'Music Lover' }, ]; } @Get(':id/following') @ApiOperation({ summary: 'List artists and users followed' }) getUserFollowing(@Param('id') id: string) { return [{ id: 'artist-001', name: 'Anirudh Ravichander', type: 'artist' }]; } }