import { Controller, Get, Post, Delete, Param, UseGuards, Req, } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; import { LibraryService } from './library.service'; import { JwtAuthGuard } from '../auth/jwt-auth.guard'; @ApiTags('Your Library') @Controller('me/library') @UseGuards(JwtAuthGuard) @ApiBearerAuth() export class LibraryController { constructor(private readonly libraryService: LibraryService) {} @Get('tracks') @ApiOperation({ summary: 'Get Liked Songs list' }) getSavedTracks(@Req() req: any) { return this.libraryService.getSavedTracks(req.user.userId); } @Post('tracks/:trackId') @ApiOperation({ summary: 'Save (like) a track' }) saveTrack(@Req() req: any, @Param('trackId') trackId: string) { return this.libraryService.saveTrack(req.user.userId, trackId); } @Delete('tracks/:trackId') @ApiOperation({ summary: 'Unsave (unlike) a track' }) unsaveTrack(@Req() req: any, @Param('trackId') trackId: string) { return this.libraryService.unsaveTrack(req.user.userId, trackId); } @Get('albums') @ApiOperation({ summary: 'Get saved albums' }) getSavedAlbums(@Req() req: any) { return this.libraryService.getSavedAlbums(req.user.userId); } @Post('albums/:albumId') @ApiOperation({ summary: 'Save an album' }) saveAlbum(@Req() req: any, @Param('albumId') albumId: string) { return this.libraryService.saveAlbum(req.user.userId, albumId); } @Delete('albums/:albumId') @ApiOperation({ summary: 'Unsave an album' }) unsaveAlbum(@Req() req: any, @Param('albumId') albumId: string) { return this.libraryService.unsaveAlbum(req.user.userId, albumId); } @Get('artists') @ApiOperation({ summary: 'Get followed artists' }) getFollowedArtists(@Req() req: any) { return this.libraryService.getFollowedArtists(req.user.userId); } @Get('playlists') @ApiOperation({ summary: 'Get owned & followed playlists' }) getUserPlaylists(@Req() req: any) { return this.libraryService.getUserPlaylists(req.user.userId); } }