diff --git a/README.md b/README.md index 3fa382b8..ef562022 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ ## 細かい変更点 +- 支援者リストをファイルから読み込む + - 外部のサーバーが落ちるとユーザーページが開けなくなることを防ぐため - 閲覧注意の注釈と画像の代替テキストもアンテナで調べる対象にする - ~~「そぎぎ」でアンテナを作れる~~ - インデックス拒否に `noindex` に加えて `nofollow,noarchive,nocache,noimageindex` も指定 diff --git a/packages/backend/src/server/api/endpoints/patrons.ts b/packages/backend/src/server/api/endpoints/patrons.ts index b5feea20..c9dc43fb 100644 --- a/packages/backend/src/server/api/endpoints/patrons.ts +++ b/packages/backend/src/server/api/endpoints/patrons.ts @@ -1,5 +1,4 @@ import define from "../define.js"; -import { redisClient } from "@/db/redis.js"; import * as fs from "node:fs"; import { fileURLToPath } from "node:url"; import { dirname } from "node:path"; @@ -24,33 +23,9 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps) => { - let patrons; - const cachedPatrons = await redisClient.get("patrons"); - if (!ps.forceUpdate && cachedPatrons) { - patrons = JSON.parse(cachedPatrons); - } else { - AbortSignal.timeout ??= function timeout(ms) { - const ctrl = new AbortController(); - setTimeout(() => ctrl.abort(), ms); - return ctrl.signal; - }; - - patrons = await fetch( - "https://gitlab.prometheus.systems/firefish/firefish/-/raw/develop/patrons.json", - { signal: AbortSignal.timeout(2000) }, - ) - .then((response) => response.json()) - .catch(() => { - const staticPatrons = JSON.parse( - fs.readFileSync( - `${_dirname}/../../../../../../patrons.json`, - "utf-8", - ), - ); - patrons = cachedPatrons ? JSON.parse(cachedPatrons) : staticPatrons; - }); - await redisClient.set("patrons", JSON.stringify(patrons), "EX", 3600); - } + const patrons = JSON.parse( + fs.readFileSync(`${_dirname}/../../../../../../patrons.json`, "utf-8"), + ); return { patrons: patrons["patrons"], sponsors: patrons["sponsors"],