feat: add some debug logs

This commit is contained in:
max_richter 2023-07-30 18:32:21 +02:00
parent af8adf9ce7
commit c7279105ca

View File

@ -93,21 +93,27 @@ export const handler = async (
const imageUrl = Deno.env.get("SILVERBULLET_SERVER") + "/" + params.image;
console.log("[api/image] " + imageUrl);
const cachedResponse = await cache.getImage({
url: imageUrl,
width: params.width,
height: params.height,
});
if (cachedResponse) {
console.log("[api/image] got cached image");
return new Response(cachedResponse.buffer.slice(), {
headers: {
"Content-Type": cachedResponse.mediaType,
},
});
} else {
console.log("[api/image] no image in cache");
}
const remoteImage = await getRemoteImage(imageUrl);
if (typeof remoteImage === "string") {
console.log("[api/image] ERROR " + remoteImage);
return new Response(remoteImage, { status: 400 });
}
@ -116,6 +122,8 @@ export const handler = async (
mode: "resize",
});
console.log("[api/image] resized image", { imageUrl });
cache.setImage(modifiedImage, {
url: imageUrl,
width: params.width,
@ -123,6 +131,8 @@ export const handler = async (
mediaType: remoteImage.mediaType,
});
console.log("[api/image] stored image in cache");
return new Response(modifiedImage, {
headers: {
"Content-Type": remoteImage.mediaType,