Spaces:
Sleeping
Sleeping
Download backend/src/modules/users/users.service.ts from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/users/users.service.ts
- Command line
-
hf download hf://spaces/kishankrish19/Chat/backend/src/modules/users/users.service.ts
-
curl -L -o users.service.ts https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/users/users.service.ts
1.89 kB
| import { Injectable, NotFoundException } from '@nestjs/common'; | |
| export interface UserProfileEntity { | |
| id: string; | |
| username: string; | |
| display_name: string; | |
| avatar_url?: string; | |
| bio?: string; | |
| country: string; | |
| account_type: 'listener' | 'artist' | 'admin'; | |
| public_playlists_count: number; | |
| followers_count: number; | |
| following_count: number; | |
| } | |
| () | |
| export class UsersService { | |
| private profiles: Map<string, UserProfileEntity> = new Map(); | |
| constructor() { | |
| this.profiles.set('user-001', { | |
| id: 'user-001', | |
| username: 'streamwave_listener', | |
| display_name: 'StreamWave Listener', | |
| avatar_url: | |
| 'https://api.dicebear.com/7.x/avataaars/svg?seed=listener@streamwave.app', | |
| bio: 'Music enthusiast & playlist curator', | |
| country: 'US', | |
| account_type: 'listener', | |
| public_playlists_count: 5, | |
| followers_count: 142, | |
| following_count: 38, | |
| }); | |
| } | |
| getPublicProfile(id: string): UserProfileEntity { | |
| const profile = this.profiles.get(id); | |
| if (!profile) { | |
| throw new NotFoundException(`User profile with ID '${id}' not found.`); | |
| } | |
| return profile; | |
| } | |
| updateProfile( | |
| id: string, | |
| dto: { | |
| display_name?: string; | |
| username?: string; | |
| bio?: string; | |
| country?: string; | |
| }, | |
| ) { | |
| const profile = this.getPublicProfile(id); | |
| if (dto.display_name) profile.display_name = dto.display_name; | |
| if (dto.username) profile.username = dto.username; | |
| if (dto.bio) profile.bio = dto.bio; | |
| if (dto.country) profile.country = dto.country; | |
| return profile; | |
| } | |
| uploadAvatar(id: string, avatarUrl: string) { | |
| const profile = this.getPublicProfile(id); | |
| profile.avatar_url = avatarUrl; | |
| return profile; | |
| } | |
| deleteAccount(id: string) { | |
| this.profiles.delete(id); | |
| return { success: true, message: 'Account deactivated successfully.' }; | |
| } | |
| } | |