Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/api/contributors.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineCachedEventHandler(
{
headers: {
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'npmx.dev',
'User-Agent': 'npmx',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every other user-agent is npmx not npmx.dev

},
},
)
Expand Down
19 changes: 5 additions & 14 deletions server/utils/docs/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,12 @@ function createLoader(): (
return undefined
}

const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS)

try {
const response = await fetch(url.toString(), {
const response = await $fetch.raw(url.toString(), {
method: 'GET',
timeout: FETCH_TIMEOUT_MS,
redirect: 'follow',
signal: controller.signal,
})
clearTimeout(timeoutId)

if (response.status !== 200) {
return undefined
Expand All @@ -115,7 +112,6 @@ function createLoader(): (
content,
}
} catch {
clearTimeout(timeoutId)
return undefined
}
}
Expand Down Expand Up @@ -156,18 +152,13 @@ function createResolver(): (specifier: string, referrer: string) => string {
async function getTypesUrl(packageName: string, version: string): Promise<string | null> {
const url = `https://esm.sh/${packageName}@${version}`

const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS)

try {
const response = await fetch(url, {
const response = await $fetch.raw(url, {
method: 'HEAD',
signal: controller.signal,
timeout: FETCH_TIMEOUT_MS,
})
clearTimeout(timeoutId)
return response.headers.get('x-typescript-types')
} catch {
clearTimeout(timeoutId)
return null
}
}
Loading