diff --git a/server/src/V2/Components/Serie.ts b/server/src/V2/Components/Serie.ts index 32bbf8b1d0..79e1524287 100644 --- a/server/src/V2/Components/Serie.ts +++ b/server/src/V2/Components/Serie.ts @@ -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 & {sets: () => Array} diff --git a/server/src/V2/endpoints/jsonEndpoints.ts b/server/src/V2/endpoints/jsonEndpoints.ts index bf6222eacb..b26cb1b3a2 100644 --- a/server/src/V2/endpoints/jsonEndpoints.ts +++ b/server/src/V2/endpoints/jsonEndpoints.ts @@ -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() @@ -95,7 +95,7 @@ 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) @@ -103,7 +103,7 @@ server case "types": case "dex-ids": result = unique( - Card.raw(lang) + Card.getAll(lang) .map((c) => c[endpointToField[endpoint]] as Array) .filter((c) => c) .reduce((p, c) => [...p, ...c], [] as Array) @@ -111,7 +111,7 @@ server break case "variants": result = unique( - Card.raw(lang) + Card.getAll(lang) .map((c) => objectKeys(c.variants ?? {}) as Array) .filter((c) => c) .reduce((p, c) => [...p, ...c], [] as Array) @@ -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: @@ -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) { diff --git a/server/src/interfaces.d.ts b/server/src/interfaces.d.ts index 1542fc247a..c3f075c813 100644 --- a/server/src/interfaces.d.ts +++ b/server/src/interfaces.d.ts @@ -26,7 +26,7 @@ export interface Query { /** * Filters used in the query */ - filters?: Partial<{ [Key in keyof T]: T[Key] | Array }> + filters?: Partial<{ [Key in keyof T]: T[Key] extends object ? string | number | Array : T[Key] | Array }> /** * data sorting