Skip to content

Commit

Permalink
✨ improve getAvatar
Browse files Browse the repository at this point in the history
  • Loading branch information
XiYang6666 committed May 12, 2024
1 parent aca8de5 commit 8ebb6b4
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions server/api/getAvatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@ import { getGravatarUrl } from "../getGravatarUrl";

const config = useRuntimeConfig();

let avatarCache: {
time: number;
value: Blob;
};

export default defineEventHandler(async (event) => {
if (avatarCache && avatarCache.time + config.avatarCacheTime >= Date.now()) {
return avatarCache.value;
}
const avatarUrl = getGravatarUrl(config.ownerEmail);
const imageBlob: Blob = await $fetch(avatarUrl);
avatarCache = {
time: Date.now(),
value: imageBlob,
};
return imageBlob;
return sendRedirect(event, getGravatarUrl(config.ownerEmail))
});

0 comments on commit 8ebb6b4

Please sign in to comment.