Florian Bouillon 7809913d18 Updated
Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net>
2021-02-03 14:02:44 +01:00

26 lines
789 B
TypeScript

import { fetchIllustrators, illustratorToIllustratorSimple } from "../illustratorUtil"
import { IllustratorsList } from "@tcgdex/sdk/interfaces/Illustrator"
import { getBaseFolder } from "../util"
import { promises as fs} from "fs"
import Logger from '@dzeio/logger'
const logger = new Logger('illustrators/index')
const lang = process.env.CARDLANG || "en"
const endpoint = getBaseFolder(lang, "illustrators")
export default async () => {
logger.log('Fetching illustrators')
const db = await fetchIllustrators()
const res: IllustratorsList = {
count: db.length,
list: db.map((ill, index) => illustratorToIllustratorSimple(ill, index))
}
await fs.mkdir(endpoint, {recursive: true})
await fs.writeFile(`${endpoint}/index.json`, JSON.stringify(res))
logger.log('Finished')
}