Spaces:
Sleeping
Sleeping
Download backend/src/modules/playlists/playlists.controller.ts from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 3.86 kB
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/playlists/playlists.controller.ts
- Command line
-
hf download hf://spaces/kishankrish19/Chat/backend/src/modules/playlists/playlists.controller.ts
-
curl -L -o playlists.controller.ts https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/playlists/playlists.controller.ts
3.86 kB
| import { | |
| Controller, | |
| Get, | |
| Post, | |
| Patch, | |
| Delete, | |
| Param, | |
| Body, | |
| UseGuards, | |
| Req, | |
| } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; | |
| import { PlaylistsService } from './playlists.service'; | |
| import { JwtAuthGuard } from '../auth/jwt-auth.guard'; | |
| ('Playlists') | |
| ('playlists') | |
| export class PlaylistsController { | |
| constructor(private readonly playlistsService: PlaylistsService) {} | |
| () | |
| ({ summary: 'List public playlists' }) | |
| getAllPlaylists() { | |
| return this.playlistsService.findAll(); | |
| } | |
| (':id') | |
| ({ summary: 'Get playlist details' }) | |
| getPlaylistById(('id') id: string) { | |
| return this.playlistsService.findOne(id); | |
| } | |
| () | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Create a new playlist' }) | |
| createPlaylist( | |
| () req: any, | |
| () | |
| dto: { | |
| title: string; | |
| description?: string; | |
| is_public?: boolean; | |
| is_collaborative?: boolean; | |
| }, | |
| ) { | |
| return this.playlistsService.create(dto, req.user?.userId); | |
| } | |
| (':id') | |
| (JwtAuthGuard) | |
| () | |
| ({ | |
| summary: 'Edit playlist title, description, or visibility flags', | |
| }) | |
| updatePlaylist(('id') id: string, () dto: any) { | |
| return this.playlistsService.update(id, dto); | |
| } | |
| (':id') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Delete a playlist' }) | |
| deletePlaylist(('id') id: string) { | |
| return this.playlistsService.remove(id); | |
| } | |
| (':id/tracks') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Add one or more tracks to a playlist' }) | |
| addTracks(('id') id: string, () body: { track_ids: string[] }) { | |
| return this.playlistsService.addTracks(id, body.track_ids || []); | |
| } | |
| (':id/tracks/:trackId') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Remove a track from a playlist' }) | |
| removeTrack(('id') id: string, ('trackId') trackId: string) { | |
| return this.playlistsService.removeTrack(id, trackId); | |
| } | |
| (':id/tracks/reorder') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Reorder playlist tracks via position indices' }) | |
| reorderTracks( | |
| ('id') id: string, | |
| () body: { from_index: number; to_index: number }, | |
| ) { | |
| return this.playlistsService.reorderTracks(id, body); | |
| } | |
| (':id/collaborators') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Invite a user as collaborative editor' }) | |
| addCollaborator(('id') id: string, () body: { user_id: string }) { | |
| return this.playlistsService.addCollaborator(id, body.user_id); | |
| } | |
| (':id/collaborators') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'List playlist collaborators' }) | |
| getCollaborators(('id') id: string) { | |
| return this.playlistsService.getCollaborators(id); | |
| } | |
| (':id/cover') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Upload custom playlist cover image' }) | |
| uploadCover(('id') id: string, () body: { cover_url: string }) { | |
| return this.playlistsService.uploadCover(id, body.cover_url); | |
| } | |
| (':id/follow') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Follow (save) another user public playlist' }) | |
| followPlaylist(() req: any, ('id') id: string) { | |
| return this.playlistsService.followPlaylist(req.user.userId, id); | |
| } | |
| (':id/follow') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Unfollow a playlist' }) | |
| unfollowPlaylist(() req: any, ('id') id: string) { | |
| return this.playlistsService.unfollowPlaylist(req.user.userId, id); | |
| } | |
| } | |