feat: list logos from the api instead of hardcoding it

This commit is contained in:
2026-02-21 22:05:26 +01:00
parent 43c91b3c54
commit 81987ac8f1
4 changed files with 32 additions and 55 deletions

22
server/api/logos.ts Normal file
View File

@@ -0,0 +1,22 @@
import { readdir } from "fs/promises";
import { join } from "path";
import { createHash } from "crypto";
const logosDir = import.meta.dev
? join(process.cwd(), "public/logos")
: join(process.cwd(), ".output/public/logos");
export default defineCachedEventHandler(async () => {
const files = await readdir(logosDir);
return files
.filter((f) => f.endsWith(".png"))
.map((f) => f.replace(/\.png$/, ""))
.sort();
}, {
maxAge: 60 * 60 * 24,
getKey: async () => {
const files = await readdir(logosDir);
const key = files.filter((f) => f.endsWith(".png")).sort().join(",");
return createHash("sha256").update(key).digest("hex");
},
});