hippofish/packages/backend/src/server/web/manifest.ts

28 lines
844 B
TypeScript
Raw Normal View History

2023-11-26 21:33:46 +01:00
import type Koa from "koa";
import { fetchMeta } from "backend-rs";
import config from "@/config/index.js";
2023-01-13 05:40:33 +01:00
import manifest from "./manifest.json" assert { type: "json" };
export const manifestHandler = async (ctx: Koa.Context) => {
2022-06-04 10:26:56 +02:00
// TODO
//const res = structuredClone(manifest);
const res = JSON.parse(JSON.stringify(manifest));
const instance = await fetchMeta(false);
2023-07-03 00:18:30 +02:00
res.short_name = instance.name || "Firefish";
res.name = instance.name || "Firefish";
if (instance.themeColor) res.theme_color = instance.themeColor;
for (const icon of res.icons) {
2023-07-25 01:03:58 +02:00
icon.src = `${icon.src}?v=${config.version.replace(/[^0-9]/g, "")}`;
}
for (const screenshot of res.screenshots) {
2023-07-25 01:03:58 +02:00
screenshot.src = `${screenshot.src}?v=${config.version.replace(
/[^0-9]/g,
"",
)}`;
}
2023-01-13 05:40:33 +01:00
ctx.set("Cache-Control", "max-age=300");
ctx.body = res;
};