feat: add stats route
Build and Deploy / build-and-deploy (push) Successful in 1m7s

This commit is contained in:
2026-07-01 17:07:40 +07:00 Unverified
parent cacfb8e6f8
commit 04b0590888
2 changed files with 22 additions and 2 deletions
+2 -2
View File
@@ -28,7 +28,7 @@ export class AssetManager {
private MAX = 300; private MAX = 300;
private approximateSize = 0; private approximateSize = 0;
private async getAssetList() { async getAssetList(): Promise<string[]> {
const [avatars, weapons, relics, pfps, namecards] = await batchStore( const [avatars, weapons, relics, pfps, namecards] = await batchStore(
"avatars", "avatars",
"weapons", "weapons",
@@ -50,7 +50,7 @@ export class AssetManager {
(p) => p.IconPath /* .replace("_Circle", "") */, (p) => p.IconPath /* .replace("_Circle", "") */,
), ),
...Object.values(namecards).map((p) => p.Icon), ...Object.values(namecards).map((p) => p.Icon),
]; ].filter((e) => e !== "None");
} }
async getMissingAssets() { async getMissingAssets() {
+20
View File
@@ -77,6 +77,26 @@ export function card(app: App) {
.derive(() => ({ .derive(() => ({
log: createLogger(), log: createLogger(),
})) }))
.get(
"/genshin/stats",
async ({ query: { with_assets } }) => {
return {
cache: assets.health,
assets:
with_assets === "" || with_assets === "true"
? await assets.getAssetList()
: "Add ?with_assets to include this array. Refer to /docs for documentation",
};
},
{
query: t.Object({
with_assets: t.String({ default: "false" }),
}),
detail: {
description: "Return stats related to cache",
},
},
)
.get("/genshin/diff", DiffPage) .get("/genshin/diff", DiffPage)
.get("/genshin/diff/ororo.png", () => file(DiffPageExample)) .get("/genshin/diff/ororo.png", () => file(DiffPageExample))
.get("/genshin/diff/listoriginal.webp", () => file(ListDiffExample)) .get("/genshin/diff/listoriginal.webp", () => file(ListDiffExample))