2024-03-20 19:32:04 +01:00
|
|
|
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
|
2024-04-27 08:57:39 -04:00
|
|
|
import { ApiTags } from '@nestjs/swagger';
|
2024-03-20 23:53:07 +01:00
|
|
|
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
|
|
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
|
|
|
|
import { PersonResponseDto } from 'src/dtos/person.dto';
|
2023-10-10 16:34:25 +02:00
|
|
|
import {
|
2024-02-12 20:50:47 -05:00
|
|
|
MetadataSearchDto,
|
2024-02-24 01:42:37 +01:00
|
|
|
PlacesResponseDto,
|
2024-03-20 23:53:07 +01:00
|
|
|
SearchExploreResponseDto,
|
2023-10-10 16:34:25 +02:00
|
|
|
SearchPeopleDto,
|
2024-02-24 01:42:37 +01:00
|
|
|
SearchPlacesDto,
|
2024-03-20 23:53:07 +01:00
|
|
|
SearchResponseDto,
|
|
|
|
|
SearchSuggestionRequestDto,
|
2024-02-12 20:50:47 -05:00
|
|
|
SmartSearchDto,
|
2024-03-20 23:53:07 +01:00
|
|
|
} from 'src/dtos/search.dto';
|
2024-03-20 15:15:01 -05:00
|
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
2024-03-21 00:07:30 +01:00
|
|
|
import { SearchService } from 'src/services/search.service';
|
2023-03-02 21:47:08 -05:00
|
|
|
|
|
|
|
|
@ApiTags('Search')
|
|
|
|
|
@Controller('search')
|
|
|
|
|
export class SearchController {
|
2023-03-24 00:53:56 -04:00
|
|
|
constructor(private service: SearchService) {}
|
2023-03-02 21:47:08 -05:00
|
|
|
|
2024-02-17 11:00:55 -06:00
|
|
|
@Post('metadata')
|
2024-03-08 11:20:54 -05:00
|
|
|
@HttpCode(HttpStatus.OK)
|
2024-05-09 13:58:44 -04:00
|
|
|
@Authenticated()
|
2024-02-17 11:00:55 -06:00
|
|
|
searchMetadata(@Auth() auth: AuthDto, @Body() dto: MetadataSearchDto): Promise<SearchResponseDto> {
|
2024-02-12 20:50:47 -05:00
|
|
|
return this.service.searchMetadata(auth, dto);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-17 11:00:55 -06:00
|
|
|
@Post('smart')
|
2024-03-08 11:20:54 -05:00
|
|
|
@HttpCode(HttpStatus.OK)
|
2024-05-09 13:58:44 -04:00
|
|
|
@Authenticated()
|
2024-02-17 11:00:55 -06:00
|
|
|
searchSmart(@Auth() auth: AuthDto, @Body() dto: SmartSearchDto): Promise<SearchResponseDto> {
|
2024-02-12 20:50:47 -05:00
|
|
|
return this.service.searchSmart(auth, dto);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-05 15:44:31 -05:00
|
|
|
@Get('explore')
|
2024-05-09 13:58:44 -04:00
|
|
|
@Authenticated()
|
2023-12-09 23:34:12 -05:00
|
|
|
getExploreData(@Auth() auth: AuthDto): Promise<SearchExploreResponseDto[]> {
|
|
|
|
|
return this.service.getExploreData(auth) as Promise<SearchExploreResponseDto[]>;
|
2023-03-05 15:44:31 -05:00
|
|
|
}
|
2023-11-25 15:46:20 +00:00
|
|
|
|
|
|
|
|
@Get('person')
|
2024-05-09 13:58:44 -04:00
|
|
|
@Authenticated()
|
2023-12-09 23:34:12 -05:00
|
|
|
searchPerson(@Auth() auth: AuthDto, @Query() dto: SearchPeopleDto): Promise<PersonResponseDto[]> {
|
|
|
|
|
return this.service.searchPerson(auth, dto);
|
2023-11-25 15:46:20 +00:00
|
|
|
}
|
2024-02-13 13:54:58 -06:00
|
|
|
|
2024-02-24 01:42:37 +01:00
|
|
|
@Get('places')
|
2024-05-09 13:58:44 -04:00
|
|
|
@Authenticated()
|
2024-02-24 01:42:37 +01:00
|
|
|
searchPlaces(@Query() dto: SearchPlacesDto): Promise<PlacesResponseDto[]> {
|
|
|
|
|
return this.service.searchPlaces(dto);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-19 23:23:57 -04:00
|
|
|
@Get('cities')
|
2024-05-09 13:58:44 -04:00
|
|
|
@Authenticated()
|
2024-03-19 23:23:57 -04:00
|
|
|
getAssetsByCity(@Auth() auth: AuthDto): Promise<AssetResponseDto[]> {
|
|
|
|
|
return this.service.getAssetsByCity(auth);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-13 13:54:58 -06:00
|
|
|
@Get('suggestions')
|
2024-05-09 13:58:44 -04:00
|
|
|
@Authenticated()
|
2024-02-13 13:54:58 -06:00
|
|
|
getSearchSuggestions(@Auth() auth: AuthDto, @Query() dto: SearchSuggestionRequestDto): Promise<string[]> {
|
2024-08-01 21:27:40 -06:00
|
|
|
// TODO fix open api generation to indicate that results can be nullable
|
|
|
|
|
return this.service.getSearchSuggestions(auth, dto) as Promise<string[]>;
|
2024-02-13 13:54:58 -06:00
|
|
|
}
|
2023-03-02 21:47:08 -05:00
|
|
|
}
|