Skip to content

Commit

Permalink
fix: build errors
Browse files Browse the repository at this point in the history
Signed-off-by: Avior <[email protected]>
  • Loading branch information
Aviortheking committed Jan 2, 2024
1 parent 56df17a commit 6ac30b3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions server/src/V2/Components/Serie.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { objectLoop } from '@dzeio/object-util'
import { Serie as SDKSerie, SerieResume, SupportedLanguages } from '@tcgdex/sdk'
import { Pagination, Query } from '../../interfaces'
import { handlePagination, handleSort, handleValidation, lightCheck } from '../../util'
import { Query } from '../../interfaces'
import { handlePagination, handleSort, handleValidation } from '../../util'
import Set from './Set'

type LocalSerie = Omit<SDKSerie, 'sets'> & {sets: () => Array<Set>}
Expand Down
26 changes: 13 additions & 13 deletions server/src/V2/endpoints/jsonEndpoints.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { objectKeys } from '@dzeio/object-util'
import { Card as SDKCard } from '@tcgdex/sdk'
import apicache from 'apicache'
import express from 'express'
import { betterSorter, checkLanguage, sendError, unique } from '../../util'
import Card from '../Components/Card'
import Serie from '../Components/Serie'
import Set from '../Components/Set'
import express from 'express'
import apicache from 'apicache'
import { betterSorter, checkLanguage, sendError, unique } from '../../util'

const server = express.Router()

Expand Down Expand Up @@ -95,23 +95,23 @@ server
case "suffixes":
case "trainer-types":
result = unique(
Card.raw(lang)
Card.getAll(lang)
.map((c) => c[endpointToField[endpoint]] as string)
.filter((c) => c)
).sort(betterSorter)
break
case "types":
case "dex-ids":
result = unique(
Card.raw(lang)
Card.getAll(lang)
.map((c) => c[endpointToField[endpoint]] as Array<string>)
.filter((c) => c)
.reduce((p, c) => [...p, ...c], [] as Array<string>)
).sort(betterSorter)
break
case "variants":
result = unique(
Card.raw(lang)
Card.getAll(lang)
.map((c) => objectKeys(c.variants ?? {}) as Array<string>)
.filter((c) => c)
.reduce((p, c) => [...p, ...c], [] as Array<string>)
Expand Down Expand Up @@ -148,23 +148,23 @@ server
let result: any | undefined
switch (endpoint) {
case 'cards':
result = Card.findOne(lang, {id})?.full()
result = Card.findOne(lang, { filters: { id }})?.full()
if (!result) {
result = Card.findOne(lang, {name: id})?.full()
result = Card.findOne(lang, { filters: { name: id }})?.full()
}
break

case 'sets':
result = Set.findOne(lang, {id})?.full()
result = Set.findOne(lang, { filters: { id }})?.full()
if (!result) {
result = Set.findOne(lang, {name: id})?.full()
result = Set.findOne(lang, {filters: { name: id }})?.full()
}
break

case 'series':
result = Serie.findOne(lang, {id})?.full()
result = Serie.findOne(lang, { filters: { id }})?.full()
if (!result) {
result = Serie.findOne(lang, {name: id})?.full()
result = Serie.findOne(lang, { filters: { name: id }})?.full()
}
break
default:
Expand Down Expand Up @@ -204,7 +204,7 @@ server
switch (endpoint) {
case 'sets':
result = Card
.findOne(lang, {localId: subid, set: id})?.full()
.findOne(lang, { filters: { localId: subid, set: id }})?.full()
break
}
if (!result) {
Expand Down
2 changes: 1 addition & 1 deletion server/src/interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface Query<T extends {} = {}> {
/**
* Filters used in the query
*/
filters?: Partial<{ [Key in keyof T]: T[Key] | Array<T[Key]> }>
filters?: Partial<{ [Key in keyof T]: T[Key] extends object ? string | number | Array<string | number> : T[Key] | Array<T[Key]> }>

/**
* data sorting
Expand Down

0 comments on commit 6ac30b3

Please sign in to comment.