chore: cleanup
This commit is contained in:
+34
-10
@@ -11,7 +11,6 @@ import {
|
||||
TTLCache,
|
||||
} from "enka.ts";
|
||||
import { twj } from "tw-to-css";
|
||||
import type { App } from "@";
|
||||
import { generateBackground } from "@/assets/background";
|
||||
import { ConstsSvg } from "@/assets/consts";
|
||||
import { featherImage } from "@/assets/feather";
|
||||
@@ -22,6 +21,7 @@ import fontFile from "@/assets/shinshin.woff2" with { type: "file" };
|
||||
import { star } from "@/assets/stars";
|
||||
import { TalentSvg } from "@/assets/talent";
|
||||
import { WeaponGlazeSvg } from "@/assets/weapon-glaze";
|
||||
import type { App } from "@/index";
|
||||
import { AssetManager, getEnkaStores } from "@/lib/assets";
|
||||
import { Deduplicator } from "@/lib/dedupe";
|
||||
import { mockData } from "@/lib/mock";
|
||||
@@ -35,6 +35,15 @@ const deduper = new Deduplicator();
|
||||
const font = file(fontFile);
|
||||
const shade = file(shadeSvg);
|
||||
|
||||
queueMicrotask(async () => {
|
||||
const assets = new AssetManager();
|
||||
assets.getMissingAssets();
|
||||
|
||||
setInterval(() => {
|
||||
assets.getMissingAssets();
|
||||
}, 86400000); // refresh assets every 24 hours
|
||||
});
|
||||
|
||||
export function card(app: App) {
|
||||
return app
|
||||
.group("/card", (app) =>
|
||||
@@ -200,15 +209,30 @@ export function card(app: App) {
|
||||
|
||||
const statRows = buildDisplayRows(char, locs);
|
||||
|
||||
if (debug)
|
||||
return JSON.stringify({
|
||||
char,
|
||||
weapon,
|
||||
assets: resources.map((e) => e.src),
|
||||
charLvl,
|
||||
charLvlMax,
|
||||
statRows,
|
||||
});
|
||||
if (debug) {
|
||||
console.log(
|
||||
`${Date.now() - start}ms - Debug endpoint, returning JSON`,
|
||||
);
|
||||
return JSON.stringify(
|
||||
{
|
||||
charLvl,
|
||||
charLvlMax,
|
||||
cacheKey,
|
||||
cache: assets.health,
|
||||
assets: Object.fromEntries(
|
||||
resources.map((e) => [
|
||||
e.src,
|
||||
`${(e.data.byteLength / 1000).toFixed(2)}Kb`,
|
||||
]),
|
||||
),
|
||||
char,
|
||||
weapon,
|
||||
statRows,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
);
|
||||
}
|
||||
|
||||
const res = new ImageResponse(
|
||||
<div tw="relative text-[32.25px] text-white rounded-xl overflow-hidden">
|
||||
|
||||
Reference in New Issue
Block a user