Files
EpicNext-Cms/src/app/api/admin/import/pets/icon/route.ts
T
openhands df38dccbf1
Local Build and Deploy / deploy (push) Failing after 46s
style: format code biome
2026-07-13 21:57:41 +02:00

22 lines
780 B
TypeScript

import { withAdmin } from "@/lib/api-handler";
import { PERMS } from "@/lib/permissions";
import { getPetIconPng } from "@/lib/services/pet-icon";
// Serves a cropped pet preview PNG extracted from the pet's .nitro spritesheet.
export const GET = withAdmin(
{ permission: PERMS.ASSETS_IMPORT },
async (request) => {
const lib = request.nextUrl.searchParams.get("lib") || "";
const png = getPetIconPng(lib);
if (!png) return new Response(null, { status: 404 });
return new Response(new Uint8Array(png), {
headers: {
"Content-Type": "image/png",
// short cache so generator tweaks show up quickly; the in-process icon
// cache keeps regeneration cheap. Client bumps a ?v= when output changes.
"Cache-Control": "public, max-age=300",
},
});
},
);