Skip to content

Commit

Permalink
reset curation module
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Jan 25, 2025
1 parent 46fe2e8 commit 8eb2d54
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/views/curation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import { fetchBuilder, FileSystemCache } from "node-fetch-cache";

import { fetchCache } from "../utils.mjs";

const minuteInMs = 60000;
const cache = new FileSystemCache({
cacheDirectory: path.resolve(env.CACHE_DIR),
ttl: minuteInMs,
});
const fetch = fetchBuilder.withCache(cache);
const fetchStaleWhileRevalidate = fetchCache(fetch, cache);

const url =
"https://opensheet.elk.sh/1R9zOdQPNo-UZqBNMvvnLig7eabKkTfMLjs1h_RGflaM/";

export async function getSheet(sheetName) {
const signal = AbortSignal.timeout(5000);
const response = await fetch(url + sheetName, { signal });
const response = await fetchStaleWhileRevalidate(url + sheetName, { signal });
if (!response.ok) {
throw new Error("Couldn't fetch the sheet");
}
Expand Down

0 comments on commit 8eb2d54

Please sign in to comment.