mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-17 12:33:22 +00:00
fix orderBy not allowing null
This commit is contained in:
@@ -25,7 +25,6 @@ import {
|
|||||||
|
|
||||||
import { JwtAuthGuard } from '../auth/guards'
|
import { JwtAuthGuard } from '../auth/guards'
|
||||||
|
|
||||||
import { CardsService } from './cards.service'
|
|
||||||
import { UpdateCardDto } from './dto'
|
import { UpdateCardDto } from './dto'
|
||||||
import { Card } from './entities/cards.entity'
|
import { Card } from './entities/cards.entity'
|
||||||
import { DeleteCardByIdCommand, GetDeckByIdCommand, UpdateCardCommand } from './use-cases'
|
import { DeleteCardByIdCommand, GetDeckByIdCommand, UpdateCardCommand } from './use-cases'
|
||||||
@@ -33,7 +32,7 @@ import { DeleteCardByIdCommand, GetDeckByIdCommand, UpdateCardCommand } from './
|
|||||||
@ApiTags('Cards')
|
@ApiTags('Cards')
|
||||||
@Controller('cards')
|
@Controller('cards')
|
||||||
export class CardsController {
|
export class CardsController {
|
||||||
constructor(private readonly decksService: CardsService, private commandBus: CommandBus) {}
|
constructor(private commandBus: CommandBus) {}
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@ApiOperation({ summary: 'Get card by id', description: 'Get card by id' })
|
@ApiOperation({ summary: 'Get card by id', description: 'Get card by id' })
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export class CardsRepository {
|
|||||||
orderBy,
|
orderBy,
|
||||||
}: GetAllCardsInDeckDto
|
}: GetAllCardsInDeckDto
|
||||||
): Promise<PaginatedCardsWithGrade> {
|
): Promise<PaginatedCardsWithGrade> {
|
||||||
if (!orderBy) {
|
if (!orderBy || orderBy === 'null') {
|
||||||
orderBy = 'updated-desc'
|
orderBy = 'updated-desc'
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import { JwtAuthGuard } from '../auth/guards'
|
|||||||
import { CreateCardDto, GetAllCardsInDeckDto } from '../cards/dto'
|
import { CreateCardDto, GetAllCardsInDeckDto } from '../cards/dto'
|
||||||
import { Card, PaginatedCards } from '../cards/entities/cards.entity'
|
import { Card, PaginatedCards } from '../cards/entities/cards.entity'
|
||||||
|
|
||||||
import { DecksService } from './decks.service'
|
|
||||||
import { CreateDeckDto, GetAllDecksDto, UpdateDeckDto } from './dto'
|
import { CreateDeckDto, GetAllDecksDto, UpdateDeckDto } from './dto'
|
||||||
import { GetRandomCardDto } from './dto/get-random-card.dto'
|
import { GetRandomCardDto } from './dto/get-random-card.dto'
|
||||||
import { Deck, DeckWithAuthor, PaginatedDecks } from './entities/deck.entity'
|
import { Deck, DeckWithAuthor, PaginatedDecks } from './entities/deck.entity'
|
||||||
@@ -52,7 +51,7 @@ import {
|
|||||||
@ApiTags('Decks')
|
@ApiTags('Decks')
|
||||||
@Controller('decks')
|
@Controller('decks')
|
||||||
export class DecksController {
|
export class DecksController {
|
||||||
constructor(private readonly decksService: DecksService, private commandBus: CommandBus) {}
|
constructor(private commandBus: CommandBus) {}
|
||||||
|
|
||||||
@HttpCode(HttpStatus.PARTIAL_CONTENT)
|
@HttpCode(HttpStatus.PARTIAL_CONTENT)
|
||||||
@ApiOperation({ description: 'Retrieve paginated decks list.', summary: 'Paginated decks list' })
|
@ApiOperation({ description: 'Retrieve paginated decks list.', summary: 'Paginated decks list' })
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export class DecksRepository {
|
|||||||
maxCardsCount,
|
maxCardsCount,
|
||||||
orderBy,
|
orderBy,
|
||||||
}: GetAllDecksDto): Promise<PaginatedDecks> {
|
}: GetAllDecksDto): Promise<PaginatedDecks> {
|
||||||
if (!orderBy) {
|
if (!orderBy || orderBy === 'null') {
|
||||||
orderBy = 'updated-desc'
|
orderBy = 'updated-desc'
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user