Chat / backend /src /modules /artists /artists.controller.ts
kishankrish19's picture
Deploy Stillwave fullstack clean
b0798af
Raw History Blame Contribute Delete
2.06 kB
import {
Controller,
Get,
Post,
Patch,
Param,
Body,
UseGuards,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { ArtistsService } from './artists.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
@ApiTags('Artists')
@Controller('artists')
export class ArtistsController {
constructor(private readonly artistsService: ArtistsService) {}
@Get(':id')
@ApiOperation({ summary: 'Get artist profile & monthly listener count' })
getArtistById(@Param('id') id: string) {
return this.artistsService.findOne(id);
}
@Get(':id/albums')
@ApiOperation({ summary: 'List artist discography (albums, EPs, singles)' })
getArtistAlbums(@Param('id') id: string) {
return this.artistsService.getAlbums(id);
}
@Get(':id/top-tracks')
@ApiOperation({ summary: 'Get top 10 tracks by play_count' })
getArtistTopTracks(@Param('id') id: string) {
return this.artistsService.getTopTracks(id);
}
@Get(':id/related')
@ApiOperation({ summary: 'Get related artists via pgvector similarity' })
getRelatedArtists(@Param('id') id: string) {
return this.artistsService.getRelated(id);
}
@Post()
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Create new artist profile (onboarding)' })
createArtist(
@Body() dto: { name: string; bio?: string; image_url?: string },
) {
return this.artistsService.create(dto);
}
@Patch(':id')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Update artist bio, image, or name' })
updateArtist(
@Param('id') id: string,
@Body() dto: { name?: string; bio?: string; image_url?: string },
) {
return this.artistsService.update(id, dto);
}
@Get(':id/monthly-listeners')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@ApiOperation({
summary: 'Time-series monthly listener counts for artist dashboard',
})
getMonthlyListeners(@Param('id') id: string) {
return this.artistsService.getMonthlyListenersTimeSeries(id);
}
}