1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-08-16 09:08:52 +00:00

fix: undefined error

This commit is contained in:
2025-08-06 15:55:33 +02:00
parent dbcac8608b
commit cdb0180092
3 changed files with 8 additions and 15 deletions

View File

@@ -101,7 +101,7 @@ export function getCompiledCard(lang: SupportedLanguages, id: string): any {
* @param lang
* @param id
*/
async function loadCard(lang: SupportedLanguages, id: string): Promise<SDKCard> {
async function loadCard(lang: SupportedLanguages, id: string): Promise<SDKCard | null> {
const key = `${id}${lang}`
const value = cache.get<SDKCard>(key)
@@ -114,6 +114,9 @@ async function loadCard(lang: SupportedLanguages, id: string): Promise<SDKCard>
// console.time('fetching DB')
// @ts-expect-error flemme
const card = list[key]
if (!card) {
return null
}
// console.timeEnd('fetching DB')
// console.time('loading providers')

View File

@@ -55,7 +55,8 @@ export async function updateTCGPlayerDatas(): Promise<boolean> {
const cacheItem = cache[item.productId] ?? {}
if (!(item.subTypeName in cacheItem)) {
cacheItem[variantMapping[item.subTypeName] ?? item.subTypeName] = objectOmit(item, 'productId', 'subTypeName')
const type = item.subTypeName.toLowerCase().replaceAll(' ', '-')
cacheItem[type] = objectOmit(item, 'productId', 'subTypeName')
}
cache[item.productId] = cacheItem
}
@@ -67,12 +68,6 @@ export async function updateTCGPlayerDatas(): Promise<boolean> {
return true
}
const variantMapping: Record<string, string> = {
Normal: 'normal',
'Reverse Holofoil': 'reverse',
'Holofoil': 'holo'
}
export async function getTCGPlayerPrice(card: { thirdParty: { tcgplayer?: number } }): Promise<{
unit: 'USD',
updated: string

View File

@@ -36,7 +36,8 @@ export async function updateTCGPlayerDatas(): Promise<boolean> {
const cacheItem = cache[item.productId] ?? {}
if (!(item.subTypeName in cacheItem)) {
cacheItem[variantMapping[item.subTypeName] ?? item.subTypeName] = objectOmit(item, 'productId', 'subTypeName')
const type = item.subTypeName.toLowerCase().replaceAll(' ', '-')
cacheItem[type] = objectOmit(item, 'productId', 'subTypeName')
}
cache[item.productId] = cacheItem
}
@@ -47,12 +48,6 @@ export async function updateTCGPlayerDatas(): Promise<boolean> {
return true
}
const variantMapping: Record<string, string> = {
Normal: 'normal',
'Reverse Holofoil': 'reverse',
'Holofoil': 'holo'
}
export async function getTCGPlayerPrice(card: { thirdParty: { tcgplayer?: number } }): Promise<{
unit: 'USD',
updated: string