main
Inga 🏳‍🌈 11 months ago
parent 52e25916de
commit 79f35168a8
  1. 6
      src/movies.controller.ts

@ -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);

Loading…
Cancel
Save