diff --git a/apps/api/src/app/cards/cards.service.ts b/apps/api/src/app/cards/cards.service.ts index cec7b180..6918ea87 100644 --- a/apps/api/src/app/cards/cards.service.ts +++ b/apps/api/src/app/cards/cards.service.ts @@ -60,7 +60,7 @@ export class CardsService { await this.storageService.getInstance() .putFile("media/sets/" + fileName, decoded); - side = side.replace(source, "/api/sets/" + setId + "/media/" + fileName); + side = side.replace(source, "/api/sets/" + setId + "/media/" + name); } } else return false; diff --git a/apps/api/src/app/cards/dto/createCard.dto.ts b/apps/api/src/app/cards/dto/createCard.dto.ts index afaf7ea4..05caff21 100644 --- a/apps/api/src/app/cards/dto/createCard.dto.ts +++ b/apps/api/src/app/cards/dto/createCard.dto.ts @@ -1,4 +1,4 @@ -import { IsNotEmpty, IsNumber, IsOptional, IsString, IsUUID, Max, MaxLength, Min } from "class-validator"; +import { IsNotEmpty, IsNumber, IsOptional, IsString, IsUUID, Max, Min } from "class-validator"; import { ApiProperty } from "@nestjs/swagger"; import { Transform, TransformFnParams } from "class-transformer"; import * as sanitizeHtml from "sanitize-html"; @@ -28,12 +28,10 @@ export class CreateCardDto { @ApiProperty({ description: "The front or \"term\" of the card", - example: "The definition of the card", - maxLength: 65535 + example: "The definition of the card" }) @IsString() @IsNotEmpty() - @MaxLength(65535) @Transform((params: TransformFnParams) => sanitizeHtml(params.value, { allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), allowedAttributes: { "img": ["src", "width", "height"], "span": ["style"] }, @@ -43,12 +41,10 @@ export class CreateCardDto { @ApiProperty({ description: "The back or \"definition\" of the card", - example: "The definition of the card", - maxLength: 65535 + example: "The definition of the card" }) @IsString() @IsNotEmpty() - @MaxLength(65535) @Transform((params: TransformFnParams) => sanitizeHtml(params.value, { allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), allowedAttributes: { "img": ["src", "width", "height"], "span": ["style"] }, diff --git a/apps/api/src/app/cards/dto/updateCard.dto.ts b/apps/api/src/app/cards/dto/updateCard.dto.ts index d83a8c15..956ea903 100644 --- a/apps/api/src/app/cards/dto/updateCard.dto.ts +++ b/apps/api/src/app/cards/dto/updateCard.dto.ts @@ -1,4 +1,4 @@ -import { IsNotEmpty, IsNumber, IsOptional, IsString, Max, MaxLength, Min } from "class-validator"; +import { IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min } from "class-validator"; import { ApiProperty } from "@nestjs/swagger"; import { Transform, TransformFnParams } from "class-transformer"; import * as sanitizeHtml from "sanitize-html"; @@ -21,13 +21,11 @@ export class UpdateCardDto { @ApiProperty({ description: "The front or \"term\" of the card", example: "The definition of the card", - maxLength: 65535, required: false }) @IsString() @IsOptional() @IsNotEmpty() - @MaxLength(65535) @Transform((params: TransformFnParams) => sanitizeHtml(params.value, { allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), allowedAttributes: { "img": ["src", "width", "height"], "span": ["style"] }, @@ -38,13 +36,11 @@ export class UpdateCardDto { @ApiProperty({ description: "The back or \"definition\" of the card", example: "The definition of the card", - maxLength: 65535, required: false }) @IsString() @IsOptional() @IsNotEmpty() - @MaxLength(65535) @Transform((params: TransformFnParams) => sanitizeHtml(params.value, { allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), allowedAttributes: { "img": ["src", "width", "height"], "span": ["style"] }, diff --git a/apps/api/src/app/folders/folders.controller.ts b/apps/api/src/app/folders/folders.controller.ts index 5aefcbad..d9d09a48 100644 --- a/apps/api/src/app/folders/folders.controller.ts +++ b/apps/api/src/app/folders/folders.controller.ts @@ -217,8 +217,6 @@ export class FoldersController { @UseGuards(AuthenticatedGuard) @Post() async createFolder(@Body(HtmlDecodePipe) body: CreateFolderDto, @Request() req: ExpressRequest): Promise> { - console.log(body); - const user = await this.authService.getUserInfo(req); if (!user) { throw new UnauthorizedException({ diff --git a/apps/api/src/app/providers/storage/provider/local.storage.ts b/apps/api/src/app/providers/storage/provider/local.storage.ts index 5908af79..410d0827 100644 --- a/apps/api/src/app/providers/storage/provider/local.storage.ts +++ b/apps/api/src/app/providers/storage/provider/local.storage.ts @@ -72,12 +72,6 @@ export class LocalStorageProvider implements StorageProvider { throw new Error(`the path provided is not a directory: "${dirPath}"`); } - for (const entity of await fs.promises.readdir(dirPath)) { - if (await this.isDirectory(nodePath.join(dirPath, entity))) { - throw new Error(`directory "${dirPath}" contains subdirectories.`); - } - } - await fs.promises.rm(dirPath, { recursive: true, force: true }); } diff --git a/apps/api/src/app/sets/validator/card.validator.ts b/apps/api/src/app/sets/validator/card.validator.ts index b1436099..f8934ec8 100644 --- a/apps/api/src/app/sets/validator/card.validator.ts +++ b/apps/api/src/app/sets/validator/card.validator.ts @@ -1,4 +1,4 @@ -import { IsNotEmpty, IsNumber, IsString, Max, MaxLength, Min } from "class-validator"; +import { IsNotEmpty, IsNumber, IsString, Max, Min } from "class-validator"; import { ApiProperty } from "@nestjs/swagger"; import { Transform, TransformFnParams } from "class-transformer"; import * as sanitizeHtml from "sanitize-html"; @@ -18,12 +18,10 @@ export class CardValidator { @ApiProperty({ description: "The front or \"term\" of the card", - example: "The term of the card", - maxLength: 65535 + example: "The term of the card" }) @IsString() @IsNotEmpty() - @MaxLength(65535) @Transform((params: TransformFnParams) => sanitizeHtml(params.value, { allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), allowedAttributes: { "img": ["src", "width", "height"], "span": ["style"] }, @@ -33,12 +31,10 @@ export class CardValidator { @ApiProperty({ description: "The back or \"definition\" of the card", - example: "The definition of the card", - maxLength: 65535 + example: "The definition of the card" }) @IsString() @IsNotEmpty() - @MaxLength(65535) @Transform((params: TransformFnParams) => sanitizeHtml(params.value, { allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), allowedAttributes: { "img": ["src", "width", "height"], "span": ["style"] }, diff --git a/apps/api/src/app/sets/validator/cardWithId.validator.ts b/apps/api/src/app/sets/validator/cardWithId.validator.ts index 006fa22f..f16d3ca6 100644 --- a/apps/api/src/app/sets/validator/cardWithId.validator.ts +++ b/apps/api/src/app/sets/validator/cardWithId.validator.ts @@ -1,4 +1,4 @@ -import { IsNotEmpty, IsNumber, IsOptional, IsString, Max, MaxLength, Min } from "class-validator"; +import { IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min } from "class-validator"; import { Transform, TransformFnParams } from "class-transformer"; import * as sanitizeHtml from "sanitize-html"; import { ApiProperty } from "@nestjs/swagger"; @@ -14,7 +14,7 @@ export class CardWithIdValidator { minLength: 36 }) @IsOptional() - id: string; + id?: string; @ApiProperty({ description: "The index of the card in the set", @@ -30,12 +30,10 @@ export class CardWithIdValidator { @ApiProperty({ description: "The front or \"term\" of the card", - example: "The term of the card", - maxLength: 65535 + example: "The term of the card" }) @IsString() @IsNotEmpty() - @MaxLength(65535) @Transform((params: TransformFnParams) => sanitizeHtml(params.value, { allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), allowedAttributes: { "img": ["src", "width", "height"], "span": ["style"] }, @@ -45,12 +43,10 @@ export class CardWithIdValidator { @ApiProperty({ description: "The back or \"definition\" of the card", - example: "The definition of the card", - maxLength: 65535 + example: "The definition of the card" }) @IsString() @IsNotEmpty() - @MaxLength(65535) @Transform((params: TransformFnParams) => sanitizeHtml(params.value, { allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), allowedAttributes: { "img": ["src", "width", "height"], "span": ["style"] },