Skip to content

Commit d7fa4fe

Browse files
committed
chore: remove try block in get author profile since we handle it in the fetch
1 parent 7cf7dc2 commit d7fa4fe

File tree

1 file changed

+14
-29
lines changed

1 file changed

+14
-29
lines changed

server/api/atproto/author-profiles.get.ts

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,39 +57,24 @@ export default defineCachedEventHandler(
5757
}
5858
}
5959

60-
try {
61-
const response = await $fetch<ProfilesResponse>(`${BLUESKY_API}app.bsky.actor.getProfiles`, {
62-
query: { actors: handles },
63-
}).catch(() => ({ profiles: [] }))
60+
const response = await $fetch<ProfilesResponse>(`${BLUESKY_API}app.bsky.actor.getProfiles`, {
61+
query: { actors: handles },
62+
}).catch(() => ({ profiles: [] }))
6463

65-
const avatarMap = new Map<string, string>()
66-
for (const profile of response.profiles) {
67-
if (profile.avatar) {
68-
avatarMap.set(profile.handle, profile.avatar)
69-
}
64+
const avatarMap = new Map<string, string>()
65+
for (const profile of response.profiles) {
66+
if (profile.avatar) {
67+
avatarMap.set(profile.handle, profile.avatar)
7068
}
69+
}
7170

72-
const resolvedAuthors: ResolvedAuthor[] = authors.map(author => ({
73-
...author,
74-
avatar: author.blueskyHandle ? avatarMap.get(author.blueskyHandle) || null : null,
75-
profileUrl: author.blueskyHandle
76-
? `https://bsky.app/profile/${author.blueskyHandle}`
77-
: null,
78-
}))
71+
const resolvedAuthors: ResolvedAuthor[] = authors.map(author => ({
72+
...author,
73+
avatar: author.blueskyHandle ? avatarMap.get(author.blueskyHandle) || null : null,
74+
profileUrl: author.blueskyHandle ? `https://bsky.app/profile/${author.blueskyHandle}` : null,
75+
}))
7976

80-
return { authors: resolvedAuthors }
81-
} catch (error) {
82-
console.error('[Author Profiles] Failed to fetch profiles:', error)
83-
return {
84-
authors: authors.map(author => ({
85-
...author,
86-
avatar: null,
87-
profileUrl: author.blueskyHandle
88-
? `https://bsky.app/profile/${author.blueskyHandle}`
89-
: null,
90-
})),
91-
}
92-
}
77+
return { authors: resolvedAuthors }
9378
},
9479
{
9580
name: 'author-profiles',

0 commit comments

Comments
 (0)