feat: add some debug logs
This commit is contained in:
parent
af8adf9ce7
commit
c7279105ca
@ -93,21 +93,27 @@ export const handler = async (
|
|||||||
|
|
||||||
const imageUrl = Deno.env.get("SILVERBULLET_SERVER") + "/" + params.image;
|
const imageUrl = Deno.env.get("SILVERBULLET_SERVER") + "/" + params.image;
|
||||||
|
|
||||||
|
console.log("[api/image] " + imageUrl);
|
||||||
|
|
||||||
const cachedResponse = await cache.getImage({
|
const cachedResponse = await cache.getImage({
|
||||||
url: imageUrl,
|
url: imageUrl,
|
||||||
width: params.width,
|
width: params.width,
|
||||||
height: params.height,
|
height: params.height,
|
||||||
});
|
});
|
||||||
if (cachedResponse) {
|
if (cachedResponse) {
|
||||||
|
console.log("[api/image] got cached image");
|
||||||
return new Response(cachedResponse.buffer.slice(), {
|
return new Response(cachedResponse.buffer.slice(), {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": cachedResponse.mediaType,
|
"Content-Type": cachedResponse.mediaType,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.log("[api/image] no image in cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteImage = await getRemoteImage(imageUrl);
|
const remoteImage = await getRemoteImage(imageUrl);
|
||||||
if (typeof remoteImage === "string") {
|
if (typeof remoteImage === "string") {
|
||||||
|
console.log("[api/image] ERROR " + remoteImage);
|
||||||
return new Response(remoteImage, { status: 400 });
|
return new Response(remoteImage, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +122,8 @@ export const handler = async (
|
|||||||
mode: "resize",
|
mode: "resize",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("[api/image] resized image", { imageUrl });
|
||||||
|
|
||||||
cache.setImage(modifiedImage, {
|
cache.setImage(modifiedImage, {
|
||||||
url: imageUrl,
|
url: imageUrl,
|
||||||
width: params.width,
|
width: params.width,
|
||||||
@ -123,6 +131,8 @@ export const handler = async (
|
|||||||
mediaType: remoteImage.mediaType,
|
mediaType: remoteImage.mediaType,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("[api/image] stored image in cache");
|
||||||
|
|
||||||
return new Response(modifiedImage, {
|
return new Response(modifiedImage, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": remoteImage.mediaType,
|
"Content-Type": remoteImage.mediaType,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user