Dashboard Verbessert
This commit is contained in:
26
src/pages/bilder/[uid].webp.ts
Normal file
26
src/pages/bilder/[uid].webp.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { createCaller } from "#lib/caller";
|
||||
import { APIRoute } from "astro";
|
||||
|
||||
export const get: APIRoute = async ({params, cookies}) => {
|
||||
const { uid } = params;
|
||||
|
||||
if (!uid) {
|
||||
return new Response("No uid provided", { status: 400 });
|
||||
}
|
||||
|
||||
const caller = createCaller({ cookies })
|
||||
|
||||
const image = await caller.v1.bilder.getBase64({ uid })
|
||||
|
||||
if (!image) {
|
||||
return new Response("No image found", { status: 404 });
|
||||
}
|
||||
|
||||
const buffer = Buffer.from(image.base64, "base64");
|
||||
|
||||
return new Response(buffer, {
|
||||
headers: {
|
||||
"Content-Type": "image/webp"
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user