2023-01-13 05:40:33 +01:00
|
|
|
import type Koa from "koa";
|
|
|
|
import { fetchMeta } from "@/misc/fetch-meta.js";
|
2023-07-21 08:31:51 +02:00
|
|
|
import config from "@/config/index.js";
|
2023-01-13 05:40:33 +01:00
|
|
|
import manifest from "./manifest.json" assert { type: "json" };
|
2019-03-31 18:05:49 +02:00
|
|
|
|
2022-02-27 03:07:39 +01:00
|
|
|
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));
|
2019-03-31 18:05:49 +02:00
|
|
|
|
2019-04-24 01:11:19 +02:00
|
|
|
const instance = await fetchMeta(true);
|
2019-03-31 18:05:49 +02:00
|
|
|
|
2023-07-03 00:18:30 +02:00
|
|
|
res.short_name = instance.name || "Firefish";
|
|
|
|
res.name = instance.name || "Firefish";
|
2022-04-23 05:38:02 +02:00
|
|
|
if (instance.themeColor) res.theme_color = instance.themeColor;
|
2023-07-21 08:31:51 +02:00
|
|
|
for (const icon of res.icons) {
|
|
|
|
icon.src = `${icon.src}?v=${config.version.replace(/[^0-9]/g, '')}`;
|
|
|
|
}
|
|
|
|
for (const screenshot of res.screenshots) {
|
|
|
|
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");
|
2022-04-23 05:38:02 +02:00
|
|
|
ctx.body = res;
|
2019-03-31 18:05:49 +02:00
|
|
|
};
|