mirror of
https://github.com/tcgdex/compiler.git
synced 2025-04-22 18:52:08 +00:00
27 lines
841 B
TypeScript
27 lines
841 B
TypeScript
import { CardList, Card as CardSingle } from '@tcgdex/sdk/interfaces'
|
|
import { Card, Languages } from '../db/interfaces'
|
|
import { Endpoint } from '../interfaces'
|
|
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
|
|
|
|
export default class implements Endpoint<CardList, CardSingle, {}, Array<[string, Card]>> {
|
|
public constructor(
|
|
private lang: keyof Languages
|
|
) {}
|
|
|
|
public async index(common: Array<[string, Card]>) {
|
|
return Promise.all(common.map((c) => cardToCardSimple(c[0], c[1], this.lang)))
|
|
}
|
|
|
|
public async item(common: Array<[string, Card]>) {
|
|
const items: Record<string, CardSingle> = {}
|
|
for (const card of common) {
|
|
items[`${card[1].set.id}-${card[0]}`] = await cardToCardSingle(card[0], card[1], this.lang)
|
|
}
|
|
return items
|
|
}
|
|
|
|
public async common() {
|
|
return getCards(this.lang)
|
|
}
|
|
}
|