Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Max, Min } from 'class-validator';
import { ArgsType, Field, Int } from 'type-graphql';
@ArgsType()
export class RecipesArgs {
@Field(type => Int)
@Min(0)
skip: number = 0;
@Field(type => Int)
@Min(1)
@Max(50)
take: number = 25;
}
import { Max, Min } from 'class-validator';
import { ArgsType, Field, Int } from 'type-graphql';
@ArgsType()
export class RecipesArgs {
@Field(type => Int)
@Min(0)
skip: number = 0;
@Field(type => Int)
@Min(1)
@Max(50)
take: number = 25;
}
@IsNumber()
@Min(1)
totalChunks: number;
}
class CreateChunksUploadTaskQuery {
@IsString()
@Transform(value => _.trim(value))
readonly key: string;
@IsString()
@Transform(value => _.trim(value))
readonly filename: string;
@IsNumber()
@Min(1)
@IsOptional()
@Transform(value => Number(value))
readonly totalChunks: number = 1;
}
@ApiTags('core')
@Controller('api/v1/uploader')
export class UploaderController {
private context = AsunaContext.instance;
constructor(private readonly uploaderService: UploaderService) {}
/**
* 创建 chunk ä¸Šä¼ ä»»åŠ¡
* @param query
* @param req
import { IsPositive, Max, Min } from "class-validator";
import { ArgsType, Field, Int } from "../../../src";
@ArgsType()
export class RecipesArgs {
@Field(type => Int)
@Min(0)
skip: number = 0;
@Field(type => Int)
@Min(1)
@Max(50)
take: number = 10;
}
*/
export abstract class PaginationParams {
/**
* Pagination limit
*/
@IsOptional()
@Min(0)
@Max(50)
@Transform((val: string) => parseInt(val, 10))
readonly take ? = 10;
/**
* Pagination offset
*/
@IsOptional()
@Min(0)
@Transform((val: string) => parseInt(val, 10))
readonly skip ? = 0;
/**
* OrderBy
*/
@IsOptional()
abstract readonly order?: { [P in keyof T]?: OrderType };
}
default: 1,
})
@Type(() => Number)
@IsInt()
@Min(1)
@IsOptional()
readonly page: number = 1;
@ApiModelPropertyOptional({
minimum: 1,
maximum: 50,
default: 10,
})
@Type(() => Number)
@IsInt()
@Min(10)
@Max(50)
@IsOptional()
readonly take: number = 10;
get skip(): number {
return (this.page - 1) * this.take;
}
@ApiModelPropertyOptional()
@IsString()
@IsNotEmpty()
@IsOptional()
readonly q?: string;
}
export class Query implements QueryInterface {
static readonly DEFAULT_RESULT_LIMIT: number = 5;
static readonly DEFAULT_RESULT_LANGUAGE: string = 'en';
@IsOptional()
@IsEnum(AccuracyEnum)
accuracy?: AccuracyEnum;
@IsOptional()
@IsString()
@MinLength(2)
@MaxLength(2)
countryCode?: string;
@IsNumber()
@Min(1)
@Max(100)
limit: number = Query.DEFAULT_RESULT_LIMIT;
@IsString()
@MinLength(2)
@MaxLength(2)
language: string = Query.DEFAULT_RESULT_LANGUAGE;
@ToBoolean()
@IsBoolean()
fillMissingQueryProperties: boolean = true;
@ToBoolean()
@IsBoolean()
withRaw: boolean = false;
}
@ApiModelProperty()
order?: string[];
@Field(() => Int, { nullable: true })
@ApiModelProperty()
@IsOptional()
@IsInt()
@Min(1)
@Max(1000)
limit?: number;
@Field(() => Int, { nullable: true })
@ApiModelProperty()
@IsOptional()
@IsInt()
@Min(0)
offset?: number;
@IsOptional()
@IsBoolean()
@Field({ nullable: true })
@ApiModelProperty()
isShowDeleted?: boolean;
@IsOptional()
@IsBoolean()
@Field(() => [String], { nullable: true })
@ApiModelProperty()
relations?: string[];
constructor(partial: Partial>) {
Object.assign(this, partial);
import { IMagiDto } from './interfaces/magi.interface';
export abstract class MagiFilter implements IFilter {
abstract where: Partial;
abstract whereOr: Partial;
@IsOptional()
@IsArray()
@ApiModelProperty({ required: false, type: String, description: '["id ASC"]' })
order?: string[];
@ApiModelProperty({ required: false })
@IsOptional()
@IsInt()
@Min(1)
@Max(1000)
limit?: number;
@ApiModelProperty({ required: false })
@IsOptional()
@IsInt()
@Min(0)
offset?: number;
@IsOptional()
@IsBoolean()
@ApiModelProperty({ required: false, type: String, description: '["relationA", "relationB"]' })
relations?: string[];
isShowDeleted?: boolean;
export class PageOptionsDto {
@ApiModelPropertyOptional({
enum: Order,
default: Order.ASC,
})
@IsEnum(Order)
@IsOptional()
readonly order: Order = Order.ASC;
@ApiModelPropertyOptional({
minimum: 1,
default: 1,
})
@Type(() => Number)
@IsInt()
@Min(1)
@IsOptional()
readonly page: number = 1;
@ApiModelPropertyOptional({
minimum: 1,
maximum: 50,
default: 10,
})
@Type(() => Number)
@IsInt()
@Min(10)
@Max(50)
@IsOptional()
readonly take: number = 10;
get skip(): number {