compiler/endpoints/illustratorUtil.ts
Florian Bouillon ef866401a4
Moved files to link with the SDK
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
2020-03-11 11:21:40 +01:00

30 lines
836 B
TypeScript

import { promises as fs} from "fs"
import * as fsSync from 'fs'
import { IllustratorSimple } from "@tcgdex/sdk/interfaces/Illustrator"
export const illustratorsFile = "./generated/illustrators.json"
let illustratorsCache: Array<string> = []
export async function fetchIllustrators(): Promise<Array<string>> {
if (illustratorsCache.length === 0) {
illustratorsCache = JSON.parse(await (await fs.readFile(illustratorsFile)).toString())
}
return illustratorsCache
}
export function fetchIllustratorsSync(): Array<string> {
if (illustratorsCache.length === 0) {
illustratorsCache = JSON.parse(fsSync.readFileSync(illustratorsFile).toString())
}
return illustratorsCache
}
export function illustratorToIllustratorSimple(illustrator: string, index: number): IllustratorSimple {
return {
id: index,
name: illustrator
}
}