mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-17 05:09:26 +00:00
fix pagination and /users
This commit is contained in:
@@ -2,8 +2,8 @@ import { isObject } from 'remeda'
|
|||||||
|
|
||||||
import { DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE } from './pagination.constants'
|
import { DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE } from './pagination.constants'
|
||||||
interface PaginationQuery {
|
interface PaginationQuery {
|
||||||
currentPage?: string
|
currentPage?: string | number
|
||||||
itemsPerPage?: string
|
itemsPerPage?: string | number
|
||||||
}
|
}
|
||||||
export class Pagination {
|
export class Pagination {
|
||||||
static getPaginationData<T extends Partial<PaginationQuery>>(
|
static getPaginationData<T extends Partial<PaginationQuery>>(
|
||||||
@@ -13,14 +13,14 @@ export class Pagination {
|
|||||||
|
|
||||||
const currentPage =
|
const currentPage =
|
||||||
'currentPage' in query &&
|
'currentPage' in query &&
|
||||||
typeof query.currentPage === 'string' &&
|
(typeof query.currentPage === 'string' || typeof query.currentPage === 'number') &&
|
||||||
!isNaN(Number(query.currentPage))
|
!isNaN(Number(query.currentPage))
|
||||||
? +query.currentPage
|
? +query.currentPage
|
||||||
: DEFAULT_PAGE_NUMBER
|
: DEFAULT_PAGE_NUMBER
|
||||||
|
|
||||||
const itemsPerPage =
|
const itemsPerPage =
|
||||||
'itemsPerPage' in query &&
|
'itemsPerPage' in query &&
|
||||||
typeof query.itemsPerPage === 'string' &&
|
(typeof query.itemsPerPage === 'string' || typeof query.itemsPerPage === 'number') &&
|
||||||
!isNaN(Number(query.itemsPerPage))
|
!isNaN(Number(query.itemsPerPage))
|
||||||
? +query.itemsPerPage
|
? +query.itemsPerPage
|
||||||
: DEFAULT_PAGE_SIZE
|
: DEFAULT_PAGE_SIZE
|
||||||
|
|||||||
Reference in New Issue
Block a user