Skip to content

Commit 70bb09f

Browse files
committed
refactor: use baseURL and a $bluesky var to call the bluesky API
1 parent 038cbc3 commit 70bb09f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

server/api/atproto/bluesky-comments.get.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ type LikesResponse = {
2626

2727
type PostsResponse = { posts: Array<{ likeCount?: number }> }
2828

29+
const $bluesky = $fetch.create({ baseURL: BLUESKY_API })
30+
2931
/**
3032
* Provides both build and runtime comments refreshes
3133
* During build, cache aggressively to avoid rate limits
@@ -48,18 +50,18 @@ export default defineCachedEventHandler(
4850
try {
4951
// Fetch thread, likes, and post metadata in parallel
5052
const [threadResponse, likesResponse, postsResponse] = await Promise.all([
51-
$fetch<ThreadResponse>(`${BLUESKY_API}app.bsky.feed.getPostThread`, {
53+
$bluesky<ThreadResponse>('/app.bsky.feed.getPostThread', {
5254
query: { uri, depth: 10 },
5355
}).catch((err: Error) => {
5456
console.warn(`[Bluesky] Thread fetch failed for ${uri}:`, err.message)
5557
return null
5658
}),
5759

58-
$fetch<LikesResponse>(`${BLUESKY_API}app.bsky.feed.getLikes`, {
60+
$bluesky<LikesResponse>('/app.bsky.feed.getLikes', {
5961
query: { uri, limit: 50 },
6062
}).catch(() => ({ likes: [] })),
6163

62-
$fetch<PostsResponse>(`${BLUESKY_API}app.bsky.feed.getPosts`, {
64+
$bluesky<PostsResponse>('/app.bsky.feed.getPosts', {
6365
query: { uris: [uri] },
6466
}).catch(() => ({ posts: [] })),
6567
])

0 commit comments

Comments
 (0)