fix: fix cache

This commit is contained in:
Pihkaal
2025-05-07 19:37:48 +02:00
parent b9053467bb
commit 5ce97cd7bf
2 changed files with 9 additions and 2 deletions

View File

@@ -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:

View File

@@ -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<QuestResult | null> => {
const history = (await response.json()) as Array<QuestResult>;
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];
};