From f6e7871fc5565fae0e7afe14d8861aabcd44e8f5 Mon Sep 17 00:00:00 2001 From: Florian BOUILLON Date: Thu, 29 Feb 2024 14:53:30 +0100 Subject: [PATCH] fix: Remove even more requires Signed-off-by: Florian BOUILLON --- server/src/V2/Components/Card.ts | 19 ++++++++++++++++++- server/src/V2/Components/Serie.ts | 18 +++++++++++++++++- server/src/V2/Components/Set.ts | 26 +++++++++++++++++++++----- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/server/src/V2/Components/Card.ts b/server/src/V2/Components/Card.ts index 5579f2839..36f015578 100644 --- a/server/src/V2/Components/Card.ts +++ b/server/src/V2/Components/Card.ts @@ -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 & {set: () => Set} interface variants { @@ -60,7 +77,7 @@ export default class Card implements LocalCard { } public static getAll(lang: SupportedLanguages): Array { - return require(`../../../generated/${lang}/cards.json`) + return cards[lang] } public static find(lang: SupportedLanguages, query: Query) { diff --git a/server/src/V2/Components/Serie.ts b/server/src/V2/Components/Serie.ts index 79e152428..860be0a3f 100644 --- a/server/src/V2/Components/Serie.ts +++ b/server/src/V2/Components/Serie.ts @@ -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 & {sets: () => Array} export default class Serie implements LocalSerie { @@ -29,7 +45,7 @@ export default class Serie implements LocalSerie { } public static getAll(lang: SupportedLanguages): Array { - return require(`../../../generated/${lang}/series.json`) + return series[lang] } public static find(lang: SupportedLanguages, query: Query) { diff --git a/server/src/V2/Components/Set.ts b/server/src/V2/Components/Set.ts index d9afbb545..3e12d6488 100644 --- a/server/src/V2/Components/Set.ts +++ b/server/src/V2/Components/Set.ts @@ -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} & Omit @@ -47,7 +63,7 @@ export default class Set implements LocalSet { } public static getAll(lang: SupportedLanguages): Array { - return require(`../../../generated/${lang}/sets.json`) + return sets[lang] } public static find(lang: SupportedLanguages, query: Query) {