reorganize some code

This commit is contained in:
tresabhi committed 2026-05-15 18:31:17 -05:00
1 parent 7011d4d20f
commit b298874f0d
24 files changed
+5 -5

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
import sharp from "sharp";
export async function imageProxy(url: string) {
if (import.meta.env.DEV) {
return Response.redirect(url);
}
let response: Response;
try {
response = await fetch(url);
} catch (error) {
console.warn(`Failed to fetch image proxy ${url}:`, error);
return new Response(null, { status: 404 });
}
const buffer = await response.arrayBuffer();
const image = sharp(buffer, { animated: true });
const webp = await image.webp().toBuffer();
const array = new Uint8Array(webp);
return new Response(array);
}