diff --git a/routes/api/images/index.ts b/routes/api/images/index.ts index c9b32cf..50eddd5 100644 --- a/routes/api/images/index.ts +++ b/routes/api/images/index.ts @@ -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,