mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-17 12:33:22 +00:00
add auth docs, add eslint import/order
This commit is contained in:
@@ -3,6 +3,7 @@ import { omit } from 'remeda'
|
||||
export const setCountKey = <K extends string, L extends string>(key: K, newKey: L) => {
|
||||
return <T extends Record<string, any>>(obj: T) => {
|
||||
obj[newKey] = obj['_count'][key]
|
||||
|
||||
return omit(obj, ['_count']) as Omit<T, '_count'> & { [P in L]: number }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IsNumber, IsOptional } from 'class-validator'
|
||||
import { Type } from 'class-transformer'
|
||||
import { IsNumber, IsOptional } from 'class-validator'
|
||||
|
||||
export class PaginationDto {
|
||||
@IsOptional()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isObject } from 'remeda'
|
||||
|
||||
import { DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE } from './pagination.constants'
|
||||
|
||||
export class Pagination {
|
||||
@@ -17,6 +18,7 @@ export class Pagination {
|
||||
!isNaN(Number(query.itemsPerPage))
|
||||
? +query.itemsPerPage
|
||||
: DEFAULT_PAGE_SIZE
|
||||
|
||||
return { currentPage, itemsPerPage, ...query }
|
||||
}
|
||||
|
||||
@@ -31,6 +33,7 @@ export class Pagination {
|
||||
}
|
||||
) {
|
||||
const totalPages = Math.ceil(count / itemsPerPage)
|
||||
|
||||
return {
|
||||
pagination: {
|
||||
totalPages,
|
||||
|
||||
@@ -2,5 +2,6 @@ import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
|
||||
export const Cookies = createParamDecorator((data: string, ctx: ExecutionContext) => {
|
||||
const request = ctx.switchToHttp().getRequest()
|
||||
|
||||
return data ? request.cookies?.[data] : request.cookies
|
||||
})
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
|
||||
import { PrismaService } from '../../prisma.service'
|
||||
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
|
||||
|
||||
@Injectable()
|
||||
export class FileUploadService {
|
||||
|
||||
Reference in New Issue
Block a user