1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-06-15 17:09:19 +00:00

Chore: upgrade deps (#483)

Co-authored-by: Avior <git@avior.me>
This commit is contained in:
2024-05-07 02:41:57 +02:00
committed by GitHub
parent c7b3267ca2
commit df154e6b9b
7 changed files with 51 additions and 32 deletions

View File

@ -1,6 +1,5 @@
import { glob } from 'glob'
import { Card, Set } from '../../../interfaces'
import glob from 'glob'
import fetch from 'node-fetch'
import * as legals from '../../../meta/legals'
interface fileCacheInterface {
@ -18,9 +17,16 @@ const fileCache: fileCacheInterface = {}
*/
export async function fetchRemoteFile<T = any>(url: string): Promise<T> {
if (!fileCache[url]) {
const signal = new AbortController()
const finished = setTimeout(() => {
signal.abort()
}, 60 * 1000);
const resp = await fetch(url, {
timeout: 60 * 1000
signal: signal.signal
})
clearTimeout(finished)
fileCache[url] = resp.json()
}
return fileCache[url]
@ -30,9 +36,7 @@ const globCache: Record<string, Array<string>> = {}
export async function smartGlob(query: string): Promise<Array<string>> {
if (!globCache[query]) {
globCache[query] = await new Promise((res) => {
glob(query, (_, matches) => res(matches))
})
globCache[query] = await glob(query)
}
return globCache[query]
}