Skip to content

Commit 36519cb

Browse files
committed
fix: use cachedFetch for all providers
1 parent 2e5b804 commit 36519cb

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

app/composables/useRepoMeta.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,13 +559,15 @@ const tangledAdapter: ProviderAdapter = {
559559
}
560560
},
561561

562-
async fetchMeta(_cachedFetch, ref, links) {
562+
async fetchMeta(cachedFetch, ref, links) {
563563
// Tangled doesn't have a public JSON API, but we can scrape the star count
564564
// from the HTML page (it's in the hx-post URL as countHint=N)
565565
try {
566-
const html = await $fetch<string>(`https://tangled.org/${ref.owner}/${ref.repo}`, {
567-
headers: { 'User-Agent': 'npmx', 'Accept': 'text/html' },
568-
})
566+
const html = await cachedFetch<string>(
567+
`https://tangled.org/${ref.owner}/${ref.repo}`,
568+
{ headers: { 'User-Agent': 'npmx', 'Accept': 'text/html' } },
569+
REPO_META_TTL,
570+
)
569571
// Extract star count from: hx-post="/star?subject=...&countHint=23"
570572
const starMatch = html.match(/countHint=(\d+)/)
571573
const stars = starMatch?.[1] ? parseInt(starMatch[1], 10) : 0
@@ -616,11 +618,17 @@ const radicleAdapter: ProviderAdapter = {
616618
}
617619
},
618620

619-
async fetchMeta(_cachedFetch, ref, links) {
620-
const res = await $fetch<RadicleProjectResponse>(
621-
`https://seed.radicle.at/api/v1/projects/${ref.repo}`,
622-
{ headers: { 'User-Agent': 'npmx' } },
623-
).catch(() => null)
621+
async fetchMeta(cachedFetch, ref, links) {
622+
let res: RadicleProjectResponse | null = null
623+
try {
624+
res = await cachedFetch<RadicleProjectResponse>(
625+
`https://seed.radicle.at/api/v1/projects/${ref.repo}`,
626+
{ headers: { 'User-Agent': 'npmx' } },
627+
REPO_META_TTL,
628+
)
629+
} catch {
630+
return null
631+
}
624632

625633
if (!res) return null
626634

0 commit comments

Comments
 (0)