|
|
@ -10,7 +10,7 @@ import { |
|
|
|
import { ApiPropertyOptional } from '@nestjs/swagger'; |
|
|
|
import { ApiPropertyOptional } from '@nestjs/swagger'; |
|
|
|
import { Type } from 'class-transformer'; |
|
|
|
import { Type } from 'class-transformer'; |
|
|
|
import { IsIn, IsInt, IsOptional, IsString, Length } from 'class-validator'; |
|
|
|
import { IsIn, IsInt, IsOptional, IsString, Length } from 'class-validator'; |
|
|
|
import { EnrichedDataService } from './types'; |
|
|
|
import { EnrichedDataService, MovieData } from './types'; |
|
|
|
|
|
|
|
|
|
|
|
const ENTRY_TYPES = ['movie', 'series', 'episode'] as const; |
|
|
|
const ENTRY_TYPES = ['movie', 'series', 'episode'] as const; |
|
|
|
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ export class MoviesController { |
|
|
|
) {} |
|
|
|
) {} |
|
|
|
|
|
|
|
|
|
|
|
@Get() |
|
|
|
@Get() |
|
|
|
searchMovies(@Query() query: SearchDto) { |
|
|
|
searchMovies(@Query() query: SearchDto): MovieData[] { |
|
|
|
if (!Object.values(query).some((filterValue) => filterValue)) { |
|
|
|
if (!Object.values(query).some((filterValue) => filterValue)) { |
|
|
|
throw new BadRequestException('Query should not be empty'); |
|
|
|
throw new BadRequestException('Query should not be empty'); |
|
|
|
} |
|
|
|
} |
|
|
@ -100,7 +100,7 @@ export class MoviesController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Get(':id') |
|
|
|
@Get(':id') |
|
|
|
getMovie(@Param('id') id: string) { |
|
|
|
getMovie(@Param('id') id: string): MovieData { |
|
|
|
const result = /^\d+$/.test(id) |
|
|
|
const result = /^\d+$/.test(id) |
|
|
|
? this.enrichedDataService.getMetadataByInternalId(parseInt(id, 10)) |
|
|
|
? this.enrichedDataService.getMetadataByInternalId(parseInt(id, 10)) |
|
|
|
: this.enrichedDataService.getMetadataByImdbId(id); |
|
|
|
: this.enrichedDataService.getMetadataByImdbId(id); |
|
|
|