diff --git a/lib/cache.ts b/lib/cache.ts index a18ce38..c1866a3 100644 --- a/lib/cache.ts +++ b/lib/cache.ts @@ -24,10 +24,6 @@ export function get(id: string) { return cache.get(id); } -export function has(id: string) { - return cache.has(id); -} - export function set(id: string, content: any) { return cache.set(id, content); } diff --git a/routes/api/recipes/images/[image].ts b/routes/api/recipes/images/[image].ts index c6fad05..3d7ffc8 100644 --- a/routes/api/recipes/images/[image].ts +++ b/routes/api/recipes/images/[image].ts @@ -108,8 +108,9 @@ export const handler = async ( } const imageId = `${imageUrl}.${params.width}.${params.height}`; - if (await cache.has(imageId)) { - return (await (await cache.get(imageId)!)).clone(); + const cachedResponse = await cache.get(imageId); + if (cachedResponse) { + return (await cachedResponse).clone(); } const remoteImage = await getRemoteImage(imageUrl);