Spaces:
Sleeping
Sleeping
Download backend/src/modules/users/users.controller.ts from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 2.44 kB
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/users/users.controller.ts
- Command line
-
hf download hf://spaces/kishankrish19/Chat/backend/src/modules/users/users.controller.ts
-
curl -L -o users.controller.ts https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/users/users.controller.ts
2.44 kB
| 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'; | |
| ('Users & Profiles') | |
| ('users') | |
| export class UsersController { | |
| constructor(private readonly usersService: UsersService) {} | |
| ('me') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Get logged-in user profile' }) | |
| getMe(() req: any) { | |
| return this.usersService.getPublicProfile(req.user.userId); | |
| } | |
| ('me') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Update logged-in user profile' }) | |
| updateMe( | |
| () req: any, | |
| () | |
| dto: { | |
| display_name?: string; | |
| username?: string; | |
| bio?: string; | |
| country?: string; | |
| }, | |
| ) { | |
| return this.usersService.updateProfile(req.user.userId, dto); | |
| } | |
| ('me/avatar') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Upload/replace profile picture' }) | |
| uploadAvatar(() req: any, () dto: { avatar_url: string }) { | |
| return this.usersService.uploadAvatar(req.user.userId, dto.avatar_url); | |
| } | |
| ('me') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Soft-delete/deactivate account' }) | |
| deleteMe(() req: any) { | |
| return this.usersService.deleteAccount(req.user.userId); | |
| } | |
| (':id') | |
| ({ summary: 'Get public user profile' }) | |
| getPublicProfile(('id') id: string) { | |
| return this.usersService.getPublicProfile(id); | |
| } | |
| (':id/playlists') | |
| ({ summary: 'List a user public playlists' }) | |
| getUserPlaylists(('id') id: string) { | |
| return [ | |
| { | |
| id: 'playlist-001', | |
| title: 'Kannada Hits & Melodies 2026', | |
| is_public: true, | |
| owner_id: id, | |
| }, | |
| ]; | |
| } | |
| (':id/followers') | |
| ({ summary: 'List followers of a user' }) | |
| getUserFollowers(('id') id: string) { | |
| return [ | |
| { id: 'user-002', username: 'music_lover', display_name: 'Music Lover' }, | |
| ]; | |
| } | |
| (':id/following') | |
| ({ summary: 'List artists and users followed' }) | |
| getUserFollowing(('id') id: string) { | |
| return [{ id: 'artist-001', name: 'Anirudh Ravichander', type: 'artist' }]; | |
| } | |
| } | |