2023-03-05 15:44:31 -05:00
|
|
|
import {
|
|
|
|
|
AuthUserDto,
|
|
|
|
|
SearchConfigResponseDto,
|
|
|
|
|
SearchDto,
|
|
|
|
|
SearchExploreResponseDto,
|
|
|
|
|
SearchResponseDto,
|
|
|
|
|
SearchService,
|
|
|
|
|
} from '@app/domain';
|
2023-03-02 21:47:08 -05:00
|
|
|
import { Controller, Get, Query, ValidationPipe } from '@nestjs/common';
|
|
|
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
|
|
|
import { GetAuthUser } from '../decorators/auth-user.decorator';
|
|
|
|
|
import { Authenticated } from '../decorators/authenticated.decorator';
|
|
|
|
|
|
|
|
|
|
@ApiTags('Search')
|
|
|
|
|
@Authenticated()
|
|
|
|
|
@Controller('search')
|
|
|
|
|
export class SearchController {
|
|
|
|
|
constructor(private readonly searchService: SearchService) {}
|
|
|
|
|
|
|
|
|
|
@Get()
|
|
|
|
|
async search(
|
|
|
|
|
@GetAuthUser() authUser: AuthUserDto,
|
2023-03-20 16:16:32 -04:00
|
|
|
@Query(new ValidationPipe({ transform: true })) dto: SearchDto,
|
2023-03-02 21:47:08 -05:00
|
|
|
): Promise<SearchResponseDto> {
|
|
|
|
|
return this.searchService.search(authUser, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get('config')
|
|
|
|
|
getSearchConfig(): SearchConfigResponseDto {
|
|
|
|
|
return this.searchService.getConfig();
|
|
|
|
|
}
|
2023-03-05 15:44:31 -05:00
|
|
|
|
|
|
|
|
@Get('explore')
|
|
|
|
|
getExploreData(@GetAuthUser() authUser: AuthUserDto): Promise<SearchExploreResponseDto[]> {
|
|
|
|
|
return this.searchService.getExploreData(authUser) as Promise<SearchExploreResponseDto[]>;
|
|
|
|
|
}
|
2023-03-02 21:47:08 -05:00
|
|
|
}
|