mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-17 05:09:26 +00:00
fix: update docs
This commit is contained in:
@@ -6,7 +6,7 @@ export class CreateDeckDto {
|
|||||||
@Length(3, 30)
|
@Length(3, 30)
|
||||||
name: string
|
name: string
|
||||||
/**
|
/**
|
||||||
* Cover image (binary)
|
* Cover image (has to be sent inside FormData, does NOT accept base64)
|
||||||
*/
|
*/
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@ApiProperty({ type: 'string', format: 'binary' })
|
@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 { 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 { PaginationDto } from '../../../infrastructure/common/pagination/pagination.dto'
|
||||||
import { IsOptionalOrEmptyString, IsOrderBy } from '../../../infrastructure/decorators'
|
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 {
|
export class GetAllDecksDto extends PaginationDto {
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@@ -34,5 +48,9 @@ export class GetAllDecksDto extends PaginationDto {
|
|||||||
* @example "name-desc"
|
* @example "name-desc"
|
||||||
* */
|
* */
|
||||||
@IsOrderBy()
|
@IsOrderBy()
|
||||||
orderBy?: string | null
|
@ApiProperty({
|
||||||
|
enum: DecksOrderBy,
|
||||||
|
})
|
||||||
|
@IsEnum(DecksOrderBy)
|
||||||
|
orderBy?: DecksOrderBy
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ export class UpdateDeckDto extends PartialType(CreateDeckDto) {
|
|||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
isPrivate?: boolean
|
isPrivate?: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cover image (has to be sent inside FormData, does NOT accept base64)
|
||||||
|
*/
|
||||||
@IsOptionalOrEmptyString()
|
@IsOptionalOrEmptyString()
|
||||||
@ApiProperty({ type: 'string', format: 'binary' })
|
@ApiProperty({ type: 'string', format: 'binary' })
|
||||||
cover?: string
|
cover?: string
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Injectable, InternalServerErrorException, Logger } from '@nestjs/common
|
|||||||
import { omit } from 'remeda'
|
import { omit } from 'remeda'
|
||||||
|
|
||||||
import { PrismaService } from '../../../prisma.service'
|
import { PrismaService } from '../../../prisma.service'
|
||||||
import { GetAllDecksDto } from '../dto'
|
import { DecksOrderBy, GetAllDecksDto } from '../dto'
|
||||||
import { Deck, PaginatedDecks } from '../entities/deck.entity'
|
import { Deck, PaginatedDecks } from '../entities/deck.entity'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -68,7 +68,7 @@ export class DecksRepository {
|
|||||||
orderBy,
|
orderBy,
|
||||||
}: GetAllDecksDto): Promise<PaginatedDecks> {
|
}: GetAllDecksDto): Promise<PaginatedDecks> {
|
||||||
if (!orderBy || orderBy === 'null') {
|
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 orderField = 'd.updated' // default order field
|
||||||
let orderDirection = 'DESC' // default order direction
|
let orderDirection = 'DESC' // default order direction
|
||||||
|
|||||||
Reference in New Issue
Block a user