fix: update docs

This commit is contained in:
2024-01-20 19:09:54 +01:00
parent 67254b5555
commit 28b5066894
4 changed files with 27 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ export class CreateDeckDto {
@Length(3, 30)
name: string
/**
* Cover image (binary)
* Cover image (has to be sent inside FormData, does NOT accept base64)
*/
@IsOptional()
@ApiProperty({ type: 'string', format: 'binary' })

View File

@@ -1,10 +1,24 @@
import { ApiHideProperty } from '@nestjs/swagger'
import { ApiHideProperty, ApiProperty } from '@nestjs/swagger'
import { Type } from 'class-transformer'
import { IsNumber, IsOptional, IsUUID } from 'class-validator'
import { IsEnum, IsNumber, IsOptional, IsUUID } from 'class-validator'
import { PaginationDto } from '../../../infrastructure/common/pagination/pagination.dto'
import { IsOptionalOrEmptyString, IsOrderBy } from '../../../infrastructure/decorators'
export enum DecksOrderBy {
'null' = 'null',
'cardsCount-asc' = 'cardsCount-asc',
'updated-asc' = 'updated-asc',
'name-asc' = 'name-asc',
'author.name-asc' = 'author.name-asc',
'created-asc' = 'created-asc',
'cardsCount-decs' = 'cardsCount-decs',
'updated-decs' = 'updated-decs',
'name-decs' = 'name-decs',
'author.name-decs' = 'author.name-decs',
'created-decs' = 'created-decs',
}
export class GetAllDecksDto extends PaginationDto {
@IsOptional()
@Type(() => Number)
@@ -34,5 +48,9 @@ export class GetAllDecksDto extends PaginationDto {
* @example "name-desc"
* */
@IsOrderBy()
orderBy?: string | null
@ApiProperty({
enum: DecksOrderBy,
})
@IsEnum(DecksOrderBy)
orderBy?: DecksOrderBy
}

View File

@@ -14,6 +14,9 @@ export class UpdateDeckDto extends PartialType(CreateDeckDto) {
@IsBoolean()
isPrivate?: boolean
/**
* Cover image (has to be sent inside FormData, does NOT accept base64)
*/
@IsOptionalOrEmptyString()
@ApiProperty({ type: 'string', format: 'binary' })
cover?: string

View File

@@ -2,7 +2,7 @@ import { Injectable, InternalServerErrorException, Logger } from '@nestjs/common
import { omit } from 'remeda'
import { PrismaService } from '../../../prisma.service'
import { GetAllDecksDto } from '../dto'
import { DecksOrderBy, GetAllDecksDto } from '../dto'
import { Deck, PaginatedDecks } from '../entities/deck.entity'
@Injectable()
@@ -68,7 +68,7 @@ export class DecksRepository {
orderBy,
}: GetAllDecksDto): Promise<PaginatedDecks> {
if (!orderBy || orderBy === 'null') {
orderBy = 'updated-desc' // Adjust this based on your actual ordering requirements
orderBy = DecksOrderBy['updated-desc'] // Adjust this based on your actual ordering requirements
}
let orderField = 'd.updated' // default order field
let orderDirection = 'DESC' // default order direction