mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-06-13 16:19:18 +00:00
feat: add boosters to API (#737)
This commit is contained in:
@ -5,6 +5,7 @@ import { CardResume, Card as CardSingle } from '../../../meta/definitions/api'
|
||||
import { getSet, setToSetSimple } from './setUtil'
|
||||
import translate from './translationUtil'
|
||||
import { DB_PATH, cardIsLegal, fetchRemoteFile, getDataFolder, getLastEdit, resolveText, smartGlob } from './util'
|
||||
import { objectMap, objectPick } from '@dzeio/object-util'
|
||||
|
||||
export async function getCardPictures(cardId: string, card: Card, lang: SupportedLanguages): Promise<string | undefined> {
|
||||
try {
|
||||
@ -108,6 +109,11 @@ export async function cardToCardSingle(localId: string, card: Card, lang: Suppor
|
||||
standard: cardIsLegal('standard', card, localId),
|
||||
expanded: cardIsLegal('expanded', card, localId)
|
||||
},
|
||||
boosters: card.boosters ? objectMap(objectPick(card.set.boosters, ...card.boosters), (booster, id) => ({
|
||||
id: `boo_${card.set.id}-${id}`,
|
||||
name: resolveText(booster.name, lang),
|
||||
// images will be coming soon...
|
||||
})) : undefined,
|
||||
updated: await getCardLastEdit(localId, card, lang)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { objectKeys } from '@dzeio/object-util'
|
||||
import { objectKeys, objectMap } from '@dzeio/object-util'
|
||||
import { Set, SupportedLanguages } from '../../../interfaces'
|
||||
import { SetResume, Set as SetSingle } from '../../../meta/definitions/api'
|
||||
import { cardToCardSimple, getCards } from './cardUtil'
|
||||
@ -106,6 +106,11 @@ export async function setToSetSingle(set: Set, lang: SupportedLanguages): Promis
|
||||
abbreviation: (set.abbreviations?.official || resolveText(set.abbreviations, lang)) ? {
|
||||
official: set.abbreviations?.official,
|
||||
localized: resolveText(set.abbreviations, lang)
|
||||
} : undefined
|
||||
} : undefined,
|
||||
boosters: set.boosters ? objectMap(set.boosters, (booster, id) => ({
|
||||
id: `boo_${set.id}-${id}`,
|
||||
name: resolveText(booster.name, lang),
|
||||
// images will be coming soon...
|
||||
})) : undefined,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user