Added ESLint

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
2021-06-22 19:54:38 +02:00
parent b951f6d2d1
commit 7014e0c511
9 changed files with 2993 additions and 845 deletions

View File

@ -1,26 +1,19 @@
// Temporary disable this as it will be rebuilt to make it like the php-sdk one
// eslint-disable-next-line max-classes-per-file
import TCGdex from './tcgdex'
export default class RequestWrapper {
private static cache: Array<Request<any>> = []
public static getRequest<T>(url: string) {
let req = this.cache.find((req) => req.url === url) as Request<T>|undefined
if (!req) {
req = new Request<T>(url)
this.cache.push(req)
}
return req
}
}
export class Request<T = any> {
public static ttl = 1000 * 60 * 60 // 1 hour
// 1 hour of TTL by default
public static ttl = 1000 * 60 * 60
private response?: T
private fetched?: Date
public constructor(
public url: string // url is public for quick url test
// url is public for quick url test
public url: string
) {}
public async get(): Promise<T | undefined> {
@ -48,4 +41,20 @@ export class Request<T = any> {
this.fetched = now
return this.response
}
}
export default class RequestWrapper {
private static cache: Array<Request<any>> = []
public static getRequest<T>(url: string): Request<T> {
let request = this.cache.find((req) => req.url === url) as Request<T>|undefined
if (!request) {
request = new Request<T>(url)
this.cache.push(request)
}
return request
}
}