Skip to content

Commit

Permalink
fix: Remove even more requires
Browse files Browse the repository at this point in the history
Signed-off-by: Florian BOUILLON <[email protected]>
  • Loading branch information
Aviortheking committed Feb 29, 2024
1 parent f9aa90e commit f6e7871
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
19 changes: 18 additions & 1 deletion server/src/V2/Components/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ import { Query } from '../../interfaces'
import { handlePagination, handleSort, handleValidation } from '../../util'
import Set from './Set'


import deCards from '../../../generated/de/cards.json'
import enCards from '../../../generated/en/cards.json'
import esCards from '../../../generated/es/cards.json'
import frCards from '../../../generated/fr/cards.json'
import itCards from '../../../generated/it/cards.json'
import ptCards from '../../../generated/pt/cards.json'

const cards = {
de: deCards,
en: enCards,
es: esCards,
fr: frCards,
it: itCards,
pt: ptCards
} as const

type LocalCard = Omit<SDKCard, 'set'> & {set: () => Set}

interface variants {
Expand Down Expand Up @@ -60,7 +77,7 @@ export default class Card implements LocalCard {
}

public static getAll(lang: SupportedLanguages): Array<SDKCard> {
return require(`../../../generated/${lang}/cards.json`)
return cards[lang]
}

public static find(lang: SupportedLanguages, query: Query<SDKCard>) {
Expand Down
18 changes: 17 additions & 1 deletion server/src/V2/Components/Serie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ import { Query } from '../../interfaces'
import { handlePagination, handleSort, handleValidation } from '../../util'
import Set from './Set'

import deSeries from '../../../generated/de/series.json'
import enSeries from '../../../generated/en/series.json'
import esSeries from '../../../generated/es/series.json'
import frSeries from '../../../generated/fr/series.json'
import itSeries from '../../../generated/it/series.json'
import ptSeries from '../../../generated/pt/series.json'

const series = {
de: deSeries,
en: enSeries,
es: esSeries,
fr: frSeries,
it: itSeries,
pt: ptSeries
} as const

type LocalSerie = Omit<SDKSerie, 'sets'> & {sets: () => Array<Set>}

export default class Serie implements LocalSerie {
Expand All @@ -29,7 +45,7 @@ export default class Serie implements LocalSerie {
}

public static getAll(lang: SupportedLanguages): Array<SDKSerie> {
return require(`../../../generated/${lang}/series.json`)
return series[lang]
}

public static find(lang: SupportedLanguages, query: Query<SDKSerie>) {
Expand Down
26 changes: 21 additions & 5 deletions server/src/V2/Components/Set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,27 @@ import { handlePagination, handleSort, handleValidation } from '../../util'
import Card from './Card'
import Serie from './Serie'

import deSets from '../../../generated/de/sets.json'
import enSets from '../../../generated/en/sets.json'
import esSets from '../../../generated/es/sets.json'
import frSets from '../../../generated/fr/sets.json'
import itSets from '../../../generated/it/sets.json'
import ptSets from '../../../generated/pt/sets.json'

const sets = {
de: deSets,
en: enSets,
es: esSets,
fr: frSets,
it: itSets,
pt: ptSets
} as const

interface variants {
normal?: boolean;
reverse?: boolean;
holo?: boolean;
firstEdition?: boolean;
normal?: boolean;
reverse?: boolean;
holo?: boolean;
firstEdition?: boolean;
}

type LocalSet = {serie: () => Serie, cards: () => Array<Card>} & Omit<SDKSet, 'serie' | 'cards'>
Expand Down Expand Up @@ -47,7 +63,7 @@ export default class Set implements LocalSet {
}

public static getAll(lang: SupportedLanguages): Array<SDKSet> {
return require(`../../../generated/${lang}/sets.json`)
return sets[lang]
}

public static find(lang: SupportedLanguages, query: Query<SDKSet>) {
Expand Down

0 comments on commit f6e7871

Please sign in to comment.