mirror of
https://github.com/tcgdex/compiler.git
synced 2025-08-07 11:21:58 +00:00
Moved files to link with the SDK
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
31
endpoints/types/index.ts
Normal file
31
endpoints/types/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import Type, { TypeSimple } from "@tcgdex/sdk/interfaces/Type"
|
||||
import TranslationUtil from "@tcgdex/sdk/TranslationUtil"
|
||||
import { getBaseFolder } from "../util"
|
||||
import { Langs } from "@tcgdex/sdk/interfaces/LangList"
|
||||
import { promises as fs } from "fs"
|
||||
import { List } from "@tcgdex/sdk/interfaces/General"
|
||||
|
||||
const lang = process.env.CARDLANG as Langs || "en"
|
||||
const endpoint = getBaseFolder(lang, "types")
|
||||
|
||||
const btsp = async () => {
|
||||
|
||||
const typeArr: Array<TypeSimple> = []
|
||||
for (const i of Object.values(Type)) {
|
||||
if (typeof i !== "number") continue
|
||||
typeArr.push({
|
||||
id: i,
|
||||
name: TranslationUtil.translate("type", i, lang)
|
||||
})
|
||||
}
|
||||
|
||||
const typeList: List<TypeSimple> = {
|
||||
count: typeArr.length,
|
||||
list: typeArr
|
||||
}
|
||||
|
||||
await fs.mkdir(endpoint, {recursive: true})
|
||||
await fs.writeFile(`${endpoint}/index.json`, JSON.stringify(typeList))
|
||||
}
|
||||
|
||||
btsp()
|
Reference in New Issue
Block a user