feat(api): normalize logo name

This commit is contained in:
2026-02-22 14:06:15 +01:00
parent 5733342619
commit 3d53660319
3 changed files with 59 additions and 21 deletions

29
server/utils/logos.ts Normal file
View File

@@ -0,0 +1,29 @@
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 const getLogoNames = cachedFunction(
async () => {
const files = await readdir(logosDir);
return files
.filter((f) => f.endsWith(".png"))
.map((f) => f.replace(/\.png$/, ""))
.sort();
},
{
maxAge: 60 * 60 * 24,
name: "logoNames",
getKey: async () => {
const files = await readdir(logosDir);
const key = files
.filter((f) => f.endsWith(".png"))
.sort()
.join(",");
return createHash("sha256").update(key).digest("hex");
},
},
);