diff --git a/docker-compose.yml b/docker-compose.yml index 1cdf784..450d9ff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,13 @@ services: - DISCORD_WEBHOOK_URL - DISCORD_MENTION - DISCORD_REWARDS_GIVER + volumes: + - cache:/app/.cache restart: always networks: web: external: true + +volumes: + cache: diff --git a/src/wov.ts b/src/wov.ts index 9306bf7..8325fe9 100644 --- a/src/wov.ts +++ b/src/wov.ts @@ -1,4 +1,5 @@ import { env } from "./env"; +import { mkdir } from "node:fs/promises"; export type QuestResult = { quest: { @@ -26,11 +27,12 @@ export const checkForNewQuest = async (): Promise => { const history = (await response.json()) as Array; const lastId = history[0].quest.id; - const cacheFile = Bun.file(".quest_cache"); + const cacheFile = Bun.file(".cache/.quest_cache"); + await mkdir(".cache", { recursive: true }); if ((await cacheFile.exists()) && (await cacheFile.text()) === lastId) { return null; } - cacheFile.write(lastId); + await cacheFile.write(lastId); return history[0]; };