Skip to content

Commit cb3791f

Browse files
committed
chore: small fixes
1 parent 792a650 commit cb3791f

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

app/pages/pds.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const usersWithAvatars = computed(() => {
5858
</p>
5959
</header>
6060

61-
<section class="prose prose-invert max-w-none space-y-12">
61+
<section class="max-w-none space-y-12">
6262
<div>
6363
<h2 class="text-lg text-fg uppercase tracking-wider mb-4">Join the Community</h2>
6464
<p class="text-fg-muted leading-relaxed mb-4">
@@ -69,7 +69,8 @@ const usersWithAvatars = computed(() => {
6969
<div class="mt-6">
7070
<LinkBase
7171
to="https://pdsmoover.com/moover/npmx.social"
72-
class="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-md border border-border hover:border-border-hover bg-bg-muted hover:bg-bg transition-colors"
72+
class="gap-2 px-4 py-2 text-sm font-medium rounded-md border border-border hover:border-border-hover bg-bg-muted hover:bg-bg"
73+
no-underline
7374
>
7475
<span class="i-lucide:arrow-right-left w-4 h-4 text-fg-muted" aria-hidden="true" />
7576
Migrate with PDS MOOver
@@ -126,10 +127,10 @@ const usersWithAvatars = computed(() => {
126127
<div v-else-if="pdsStatus === 'error'" class="text-fg-subtle text-sm" role="alert">
127128
Failed to load PDS community.
128129
</div>
129-
<ul
130-
v-else-if="usersWithAvatars.length"
131-
class="grid grid-cols-[repeat(auto-fill,48px)] gap-2 list-none p-0"
132-
>
130+
<div v-else-if="!usersWithAvatars.length" class="text-fg-subtle text-sm">
131+
No community members to display.
132+
</div>
133+
<ul v-else class="grid grid-cols-[repeat(auto-fill,48px)] gap-2 list-none p-0">
133134
<li v-for="user in usersWithAvatars" :key="user.handle" class="block group relative">
134135
<a
135136
:href="`https://bsky.app/profile/${user.handle}`"

server/api/atproto/pds-graphs.get.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,46 @@
1-
import type { AtprotoProfile } from '~~/server/api/atproto/pds-users.get'
1+
import type { AtprotoProfile } from '#shared/types/atproto'
2+
3+
import {
4+
ONE_THOUSAND_NPMX_USER_ACCOUNTS_XRPC,
5+
BSKY_APP_VIEW_USER_PROFILES_XRPC,
6+
ERROR_PDS_FETCH_FAILED,
7+
} from '#shared/utils/constants'
28

39
interface GraphLink {
410
source: string
511
target: string
612
}
713

14+
const USER_BATCH_AMOUNT = 25
15+
816
export default defineCachedEventHandler(
917
async (): Promise<{ nodes: AtprotoProfile[]; links: GraphLink[] }> => {
10-
const response = await fetch('https://npmx.social/xrpc/com.atproto.sync.listRepos?limit=1000')
18+
const response = await fetch(ONE_THOUSAND_NPMX_USER_ACCOUNTS_XRPC)
1119

1220
if (!response.ok) {
1321
throw createError({
1422
statusCode: response.status,
15-
message: 'Failed to fetch PDS repos',
23+
message: ERROR_PDS_FETCH_FAILED,
1624
})
1725
}
1826

1927
const listRepos = (await response.json()) as { repos: { did: string }[] }
2028
const dids = listRepos.repos.map(repo => repo.did)
2129
const localDids = new Set(dids)
2230

23-
const getProfilesUrl = 'https://public.api.bsky.app/xrpc/app.bsky.actor.getProfiles'
2431
const nodes: AtprotoProfile[] = []
2532
const links: GraphLink[] = []
2633

27-
for (let i = 0; i < dids.length; i += 25) {
28-
const batch = dids.slice(i, i + 25)
34+
for (let i = 0; i < dids.length; i += USER_BATCH_AMOUNT) {
35+
const batch = dids.slice(i, i + USER_BATCH_AMOUNT)
2936

30-
const params = new URLSearchParams()
37+
const url = new URL(BSKY_APP_VIEW_USER_PROFILES_XRPC)
3138
for (const did of batch) {
32-
params.append('actors', did)
39+
url.searchParams.append('actors', did)
3340
}
3441

3542
try {
36-
const profilesResponse = await fetch(`${getProfilesUrl}?${params.toString()}`)
43+
const profilesResponse = await fetch(url.toString())
3744

3845
if (!profilesResponse.ok) {
3946
console.warn(`Failed to fetch atproto profiles: ${profilesResponse.status}`)
@@ -56,7 +63,7 @@ export default defineCachedEventHandler(
5663
)
5764

5865
if (!followResponse.ok) {
59-
console.warn(`Failed to fetch atproto profiles: ${followResponse.status}`)
66+
console.warn(`Failed to fetch follows: ${followResponse.status}`)
6067
continue
6168
}
6269

@@ -73,4 +80,9 @@ export default defineCachedEventHandler(
7380
links,
7481
}
7582
},
83+
{
84+
maxAge: 3600,
85+
name: 'pds-graphs',
86+
getKey: () => 'pds-graphs',
87+
},
7688
)

0 commit comments

Comments
 (0)