mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-16 20:59:26 +00:00
fix: update docs
This commit is contained in:
@@ -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' })
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user