diff --git a/backend/src/api-keys/api-keys.controller.ts b/backend/src/api-keys/api-keys.controller.ts index 2d65beb..0c75958 100644 --- a/backend/src/api-keys/api-keys.controller.ts +++ b/backend/src/api-keys/api-keys.controller.ts @@ -11,6 +11,7 @@ import { import { AuthGuard } from "../auth/guards/auth.guard"; import type { AuthenticatedRequest } from "../common/interfaces/request.interface"; import { ApiKeysService } from "./api-keys.service"; +import { CreateApiKeyDto } from "./dto/create-api-key.dto"; @Controller("api-keys") @UseGuards(AuthGuard) @@ -20,13 +21,12 @@ export class ApiKeysController { @Post() create( @Req() req: AuthenticatedRequest, - @Body("name") name: string, - @Body("expiresAt") expiresAt?: string, + @Body() createApiKeyDto: CreateApiKeyDto, ) { return this.apiKeysService.create( req.user.sub, - name, - expiresAt ? new Date(expiresAt) : undefined, + createApiKeyDto.name, + createApiKeyDto.expiresAt ? new Date(createApiKeyDto.expiresAt) : undefined, ); } diff --git a/backend/src/api-keys/dto/create-api-key.dto.ts b/backend/src/api-keys/dto/create-api-key.dto.ts new file mode 100644 index 0000000..91601a6 --- /dev/null +++ b/backend/src/api-keys/dto/create-api-key.dto.ts @@ -0,0 +1,12 @@ +import { IsDateString, IsNotEmpty, IsOptional, IsString, MaxLength } from "class-validator"; + +export class CreateApiKeyDto { + @IsString() + @IsNotEmpty() + @MaxLength(128) + name!: string; + + @IsOptional() + @IsDateString() + expiresAt?: string; +} diff --git a/backend/src/categories/dto/create-category.dto.ts b/backend/src/categories/dto/create-category.dto.ts index 52e0884..1459f00 100644 --- a/backend/src/categories/dto/create-category.dto.ts +++ b/backend/src/categories/dto/create-category.dto.ts @@ -1,15 +1,18 @@ -import { IsNotEmpty, IsOptional, IsString } from "class-validator"; +import { IsNotEmpty, IsOptional, IsString, MaxLength } from "class-validator"; export class CreateCategoryDto { @IsString() @IsNotEmpty() + @MaxLength(64) name!: string; @IsOptional() @IsString() + @MaxLength(255) description?: string; @IsOptional() @IsString() + @MaxLength(512) iconUrl?: string; } diff --git a/backend/src/contents/dto/create-content.dto.ts b/backend/src/contents/dto/create-content.dto.ts index 096601e..7c0aa92 100644 --- a/backend/src/contents/dto/create-content.dto.ts +++ b/backend/src/contents/dto/create-content.dto.ts @@ -6,6 +6,7 @@ import { IsOptional, IsString, IsUUID, + MaxLength, } from "class-validator"; export enum ContentType { @@ -19,14 +20,17 @@ export class CreateContentDto { @IsString() @IsNotEmpty() + @MaxLength(255) title!: string; @IsString() @IsNotEmpty() + @MaxLength(512) storageKey!: string; @IsString() @IsNotEmpty() + @MaxLength(128) mimeType!: string; @IsInt() @@ -39,5 +43,6 @@ export class CreateContentDto { @IsOptional() @IsArray() @IsString({ each: true }) + @MaxLength(64, { each: true }) tags?: string[]; } diff --git a/backend/src/contents/dto/upload-content.dto.ts b/backend/src/contents/dto/upload-content.dto.ts index ca4b284..a67c3d7 100644 --- a/backend/src/contents/dto/upload-content.dto.ts +++ b/backend/src/contents/dto/upload-content.dto.ts @@ -4,6 +4,7 @@ import { IsOptional, IsString, IsUUID, + MaxLength, } from "class-validator"; import { ContentType } from "./create-content.dto"; @@ -13,6 +14,7 @@ export class UploadContentDto { @IsString() @IsNotEmpty() + @MaxLength(255) title!: string; @IsOptional() @@ -20,6 +22,8 @@ export class UploadContentDto { categoryId?: string; @IsOptional() + @IsArray() @IsString({ each: true }) + @MaxLength(64, { each: true }) tags?: string[]; } diff --git a/backend/src/reports/dto/create-report.dto.ts b/backend/src/reports/dto/create-report.dto.ts index 4a5284d..53a9bae 100644 --- a/backend/src/reports/dto/create-report.dto.ts +++ b/backend/src/reports/dto/create-report.dto.ts @@ -1,4 +1,4 @@ -import { IsEnum, IsOptional, IsString, IsUUID } from "class-validator"; +import { IsEnum, IsOptional, IsString, IsUUID, MaxLength } from "class-validator"; export enum ReportReason { INAPPROPRIATE = "inappropriate", @@ -21,5 +21,6 @@ export class CreateReportDto { @IsOptional() @IsString() + @MaxLength(1000) description?: string; } diff --git a/backend/src/users/dto/update-consent.dto.ts b/backend/src/users/dto/update-consent.dto.ts index 3456a81..aa97e7e 100644 --- a/backend/src/users/dto/update-consent.dto.ts +++ b/backend/src/users/dto/update-consent.dto.ts @@ -1,11 +1,13 @@ -import { IsNotEmpty, IsString } from "class-validator"; +import { IsNotEmpty, IsString, MaxLength } from "class-validator"; export class UpdateConsentDto { @IsString() @IsNotEmpty() + @MaxLength(16) termsVersion!: string; @IsString() @IsNotEmpty() + @MaxLength(16) privacyVersion!: string; }