File size: 898 Bytes
b0798af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Controller, Get, Query } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { SearchService } from './search.service';

@ApiTags('Search & Browse')
@Controller()
export class SearchController {
  constructor(private readonly searchService: SearchService) {}

  @Get('search')
  @ApiOperation({
    summary:
      'Full-text + fuzzy search across tracks, artists, albums, playlists',
  })
  search(@Query('q') q: string, @Query('type') type?: string) {
    return this.searchService.search(q || '', type);
  }

  @Get('search/suggest')
  @ApiOperation({ summary: 'Type-ahead search suggestions' })
  suggest(@Query('q') q: string) {
    return this.searchService.suggest(q || '');
  }

  @Get('browse/categories')
  @ApiOperation({ summary: 'Genre & mood browse category tiles' })
  getCategories() {
    return this.searchService.getCategories();
  }
}