fix: fix cache
This commit is contained in:
@@ -12,8 +12,13 @@ services:
|
|||||||
- DISCORD_WEBHOOK_URL
|
- DISCORD_WEBHOOK_URL
|
||||||
- DISCORD_MENTION
|
- DISCORD_MENTION
|
||||||
- DISCORD_REWARDS_GIVER
|
- DISCORD_REWARDS_GIVER
|
||||||
|
volumes:
|
||||||
|
- cache:/app/.cache
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
web:
|
web:
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
cache:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { env } from "./env";
|
import { env } from "./env";
|
||||||
|
import { mkdir } from "node:fs/promises";
|
||||||
|
|
||||||
export type QuestResult = {
|
export type QuestResult = {
|
||||||
quest: {
|
quest: {
|
||||||
@@ -26,11 +27,12 @@ export const checkForNewQuest = async (): Promise<QuestResult | null> => {
|
|||||||
const history = (await response.json()) as Array<QuestResult>;
|
const history = (await response.json()) as Array<QuestResult>;
|
||||||
|
|
||||||
const lastId = history[0].quest.id;
|
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) {
|
if ((await cacheFile.exists()) && (await cacheFile.text()) === lastId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheFile.write(lastId);
|
await cacheFile.write(lastId);
|
||||||
return history[0];
|
return history[0];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user