1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-06-15 08:59:18 +00:00

feat: Add status Dashboard (#187)

* feat: Add status Dashboard

Still need some polishing like using the compiler instead of the live DB

Signed-off-by: Avior <github@avior.me>

* refactor: Simplified compiler files generators

Signed-off-by: Avior <florian.bouillon@delta-wings.net>

* chore: Add step to compiler for stats and optimize

Signed-off-by: Avior <github@avior.me>

* refactor: Remove unused variable

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
2021-11-23 15:12:50 +00:00
committed by GitHub
parent 8ef099273e
commit 762ce389c1
18 changed files with 431 additions and 142 deletions

View File

@ -1,30 +1,10 @@
import { Card as CardSingle, CardResume } from '../../../meta/definitions/api'
import { Card, Languages } from '../../../interfaces'
import { Endpoint } from '../compilerInterfaces'
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
type CardList = Array<CardResume>
export default class implements Endpoint<CardList, CardSingle, Record<string, unknown>, Array<[string, Card]>> {
public constructor(
private lang: keyof Languages
) {}
public async index(common: Array<[string, Card]>): Promise<CardList> {
return Promise.all(common.map((c) => cardToCardSimple(c[0], c[1], this.lang)))
}
public async item(common: Array<[string, Card]>): Promise<Record<string, CardSingle>> {
const items: Record<string, CardSingle> = {}
for await (const card of common) {
items[`${card[1].set.id}-${card[0]}`] = await cardToCardSingle(card[0], card[1], this.lang)
}
return items
}
public async common(): Promise<Array<[string, Card]>> {
return getCards(this.lang)
}
import { SupportedLanguages } from '../../../interfaces'
import { FileFunction } from '../compilerInterfaces'
import { cardToCardSingle, getCards } from '../utils/cardUtil'
const fn: FileFunction = async (lang: SupportedLanguages) => {
const common = await getCards(lang)
return await Promise.all(common.map((card) => cardToCardSingle(card[0], card[1], lang)))
}
export default fn