mirror of
https://github.com/tcgdex/compiler.git
synced 2025-04-22 02:32:10 +00:00
* Done ! Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net> * ACT doesn't wanna work so I push Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net> * Continued work on ESLint Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net> * Two files remaining Signed-off-by: Avior <github@avior.me> * Fixed set cards not found when using ids Signed-off-by: Avior <florian.bouillon@delta-wings.net>
32 lines
999 B
TypeScript
32 lines
999 B
TypeScript
import { Serie as SerieSingle, SerieList, SerieResume } from '@tcgdex/sdk/interfaces'
|
|
import { Languages, Serie } from '../db/interfaces'
|
|
import { Endpoint } from '../interfaces'
|
|
import { getSeries, serieToSerieSimple, serieToSerieSingle } from '../utils/serieUtil'
|
|
|
|
export default class implements Endpoint<SerieList, SerieSingle, Record<string, any>, Array<Serie>> {
|
|
|
|
public constructor(
|
|
private lang: keyof Languages
|
|
) {}
|
|
|
|
public async index(common: Array<Serie>): Promise<Array<SerieResume>> {
|
|
return Promise.all(common.map((s) => serieToSerieSimple(s, this.lang)))
|
|
}
|
|
|
|
public async item(common: Array<Serie>): Promise<Record<string, SerieSingle>> {
|
|
const items: Record<string, SerieSingle> = {}
|
|
for await (const val of common) {
|
|
const gen = await serieToSerieSingle(val, this.lang)
|
|
const name = val.name[this.lang] as string
|
|
items[name] = gen
|
|
items[val.id] = gen
|
|
}
|
|
return items
|
|
}
|
|
|
|
public async common(): Promise<Array<Serie>> {
|
|
return getSeries(this.lang)
|
|
}
|
|
|
|
}
|