Spaces:
Sleeping
Sleeping
Download backend/src/modules/tracks/tracks.controller.ts from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 3.07 kB
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/tracks/tracks.controller.ts
- Command line
-
hf download hf://spaces/kishankrish19/Chat/backend/src/modules/tracks/tracks.controller.ts
-
curl -L -o tracks.controller.ts https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/tracks/tracks.controller.ts
3.07 kB
| import { | |
| Controller, | |
| Get, | |
| Post, | |
| Patch, | |
| Delete, | |
| Param, | |
| Body, | |
| UseGuards, | |
| Res, | |
| } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; | |
| import { TracksService } from './tracks.service'; | |
| import { JwtAuthGuard } from '../auth/jwt-auth.guard'; | |
| ('Tracks') | |
| ('tracks') | |
| export class TracksController { | |
| constructor(private readonly tracksService: TracksService) {} | |
| () | |
| ({ summary: 'List published music tracks' }) | |
| getAllTracks() { | |
| return this.tracksService.findAll(); | |
| } | |
| ('on-repeat') | |
| ({ summary: 'Get user On Repeat frequently played tracks' }) | |
| getOnRepeatTracks() { | |
| return this.tracksService.getOnRepeatTracks(); | |
| } | |
| ('download-demand') | |
| ({ | |
| summary: 'Trigger non-blocking background on-demand track download', | |
| }) | |
| downloadOnDemand(() body: { track_id: string }) { | |
| return this.tracksService.downloadOnDemand(body.track_id); | |
| } | |
| ('download-status/:trackId') | |
| ({ summary: 'Check background download job status' }) | |
| getDownloadStatus(('trackId') trackId: string) { | |
| return this.tracksService.getDownloadStatus(trackId); | |
| } | |
| (':id') | |
| ({ summary: 'Get track metadata by ID' }) | |
| getTrackById(('id') id: string) { | |
| return this.tracksService.findOne(id); | |
| } | |
| (':id/lyrics') | |
| ({ summary: 'Get plain or time-synced lyrics for a track' }) | |
| getLyrics(('id') id: string) { | |
| return this.tracksService.getLyrics(id); | |
| } | |
| (':id/stream') | |
| ({ summary: 'Get short-lived signed audio streaming URL' }) | |
| getStreamUrl(('id') id: string) { | |
| return this.tracksService.getStreamUrl(id); | |
| } | |
| (':id/audio') | |
| ({ summary: 'Direct binary audio stream or CDN redirect' }) | |
| async streamAudio(('id') id: string, () res: any) { | |
| return this.tracksService.streamAudio(id, res); | |
| } | |
| () | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Upload/create a new track' }) | |
| createTrack( | |
| () | |
| dto: { | |
| title: string; | |
| artist_name: string; | |
| album_title?: string; | |
| duration_ms: number; | |
| audio_path: string; | |
| cover_url?: string; | |
| explicit?: boolean; | |
| }, | |
| ) { | |
| return this.tracksService.create(dto); | |
| } | |
| (':id') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Edit track metadata' }) | |
| updateTrack(('id') id: string, () dto: any) { | |
| return this.tracksService.update(id, dto); | |
| } | |
| (':id') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Remove a track' }) | |
| removeTrack(('id') id: string) { | |
| return this.tracksService.remove(id); | |
| } | |
| (':id/play') | |
| ({ summary: 'Log a play event (context, ms_played)' }) | |
| logPlay( | |
| ('id') id: string, | |
| () | |
| body: { context_type?: string; context_id?: string; ms_played?: number }, | |
| ) { | |
| return this.tracksService.logPlay(id, body); | |
| } | |
| } | |