refactor: improve typing in backend (#748)

This commit is contained in:
Carlos Valente
2024-01-30 21:12:19 +01:00
committed by GitHub
parent 39711c1edd
commit 6a5020424b
26 changed files with 703 additions and 147 deletions
+3 -3
View File
@@ -14,7 +14,7 @@ export function getCached<T>(key: string, callback: () => T): T {
const data = callback();
runtimeCache.set(key, { data });
} catch (error) {
console.log(`Failed retrieving data from callback: ${error}`);
console.error(`Failed retrieving data from callback: ${error}`);
}
}
@@ -23,10 +23,10 @@ export function getCached<T>(key: string, callback: () => T): T {
export function setCached<T>(key: string, value: T): T {
runtimeCache.set(key, { data: value });
return runtimeCache.get(key).data as T;
return value;
}
export function invalidate(key) {
export function invalidate(key: string) {
runtimeCache.delete(key);
}