26 lines
559 B
TypeScript
26 lines
559 B
TypeScript
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"
|
|
}
|
|
});
|
|
} |