From 831e0504c6f261e2ae85fb6f36c4d1a759d50048 Mon Sep 17 00:00:00 2001 From: Owen Date: Sun, 14 Jul 2024 22:17:55 +0100 Subject: [PATCH] dont dynamic import TTLCache --- src/api/squaremap/Nations.ts | 2 +- src/helpers/DataHandler.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/squaremap/Nations.ts b/src/api/squaremap/Nations.ts index eedd243..acdfa02 100644 --- a/src/api/squaremap/Nations.ts +++ b/src/api/squaremap/Nations.ts @@ -42,7 +42,7 @@ class Nations implements EntityApi { try { town = await this.map.Towns.get(townName) as SquaremapTown } catch (_) { - throw new FetchError(`Specified town '${townName}' does not exist!`) + throw new FetchError(`Specified town \`${townName}\` does not exist!`) } const nations = await this.all(this.map.getFromCache('towns')) diff --git a/src/helpers/DataHandler.ts b/src/helpers/DataHandler.ts index 5b5d4b2..9344d9c 100644 --- a/src/helpers/DataHandler.ts +++ b/src/helpers/DataHandler.ts @@ -3,11 +3,13 @@ import * as endpoint from '../utils/endpoint.js' import { Mutex } from 'async-mutex' import type { AnyMap } from '../types/index.js' +import TTLCache from '@isaacs/ttlcache' + class DataHandler { #map: AnyMap get map() { return this.#map } - #cache: any + #cache: TTLCache #cacheTTL: number #cacheLock: Mutex @@ -26,7 +28,7 @@ class DataHandler { let cacheInstance = null try { - cacheInstance = import('@isaacs/ttlcache').then(tc => new tc.default({ ttl: this.#cacheTTL })) + cacheInstance = new TTLCache({ ttl: this.#cacheTTL }) } catch (e) { console.error(e) } finally {