Update in progress

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
2021-02-03 01:14:26 +01:00
parent 557dad7e33
commit 1e4a9ba9d1
27 changed files with 272 additions and 92 deletions

View File

@ -3,12 +3,15 @@ import Category, { CategorySimple, CategoryList } from '@tcgdex/sdk/interfaces/C
import TranslationUtil from "@tcgdex/sdk/TranslationUtil"
import { Langs } from "@tcgdex/sdk/interfaces/LangList"
import { promises as fs } from 'fs'
import Logger from '@dzeio/logger'
const lang = process.env.CARDLANG as Langs || "en"
const endpoint = getBaseFolder(lang, "categories")
const logger = new Logger('Category/Index')
export default async () => {
console.log(endpoint)
logger.log(endpoint)
const list: Array<CategorySimple> = []
for (const cat of Object.values(Category)) {
@ -26,5 +29,5 @@ export default async () => {
await fs.mkdir(endpoint, {recursive: true})
await fs.writeFile(`${endpoint}/index.json`, JSON.stringify(res))
console.log('ended ' + endpoint)
logger.log('ended')
}

View File

@ -37,7 +37,7 @@ export default async () => {
const toSave: CategorySingle = {
id: rCat,
name: TranslationUtil.translate("category", rCat, lang),
cards: cards.map(el => cardToCardSimple(el, lang))
cards: await Promise.all(cards.map(el => cardToCardSimple(el, lang)))
}
const index = `${endpoint}/${toSave.id}`