Skip to content
Snippets Groups Projects
Commit a7a4773b authored by Lukáš Kratochvíl's avatar Lukáš Kratochvíl
Browse files

feat: extended movies API GET query parameters

parent 8099a309
No related branches found
No related tags found
No related merge requests found
import { ApiPropertyOptional } from "@nestjs/swagger"; import { ApiPropertyOptional } from "@nestjs/swagger";
import { Transform } from "class-transformer"; import { Transform, Type } from "class-transformer";
import { IsOptional, IsPositive } from "class-validator"; import { IsOptional, IsPositive, IsString, IsUUID, ValidateNested } from "class-validator";
class Runtime {
@Transform(({ value }) => +value)
@IsOptional()
@IsPositive()
@ApiPropertyOptional({name: 'runtime[gte]'})
gte?: number;
@Transform(({ value }) => +value)
@IsOptional()
@IsPositive()
@ApiPropertyOptional({name: 'runtime[lte]'})
lte?: number;
}
class Published {
@Transform(({ value }) => +value)
@IsOptional()
@IsPositive()
@ApiPropertyOptional({name: 'published[gte]'})
gte?: number;
@Transform(({ value }) => +value)
@IsOptional()
@IsPositive()
@ApiPropertyOptional({name: 'published[lte]'})
lte?: number;
}
export class IMoviesQuery { export class IMoviesQuery {
@Transform(({ value }) => +value) @Transform(({ value }) => +value)
...@@ -8,4 +36,36 @@ export class IMoviesQuery { ...@@ -8,4 +36,36 @@ export class IMoviesQuery {
@IsPositive() @IsPositive()
@ApiPropertyOptional({name: 'mostRecentCnt'}) @ApiPropertyOptional({name: 'mostRecentCnt'})
mostRecentCnt?: number; mostRecentCnt?: number;
@IsOptional()
@IsString()
@ApiPropertyOptional({name: 'name'})
name?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional({name: 'origName'})
originalName?: string;
@ValidateNested({ each: true })
@Type(() => Runtime)
@IsOptional()
@ApiPropertyOptional({ type: () => Runtime })
runtime?: Runtime;
@ValidateNested({ each: true })
@Type(() => Published)
@IsOptional()
@ApiPropertyOptional({ type: () => Published })
published?: Published;
@IsOptional()
@IsUUID()
@ApiPropertyOptional({name: 'categoryId'})
categoryId?: string;
@IsOptional()
@IsUUID()
@ApiPropertyOptional({name: 'directorId'})
directorId?: string;
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment