|
1 | 1 | import type { ProviderId, RepoRef } from '#shared/utils/git-providers' |
2 | | -import { parseRepoUrl, GITLAB_HOSTS } from '#shared/utils/git-providers' |
| 2 | +import { GIT_PROVIDER_API_ORIGINS, parseRepoUrl, GITLAB_HOSTS } from '#shared/utils/git-providers' |
3 | 3 |
|
4 | 4 | // TTL for git repo metadata (10 minutes - repo stats don't change frequently) |
5 | 5 | const REPO_META_TTL = 60 * 10 |
@@ -132,7 +132,7 @@ const githubAdapter: ProviderAdapter = { |
132 | 132 | let res: UnghRepoResponse | null = null |
133 | 133 | try { |
134 | 134 | const { data } = await cachedFetch<UnghRepoResponse>( |
135 | | - `https://ungh.cc/repos/${ref.owner}/${ref.repo}`, |
| 135 | + `${GIT_PROVIDER_API_ORIGINS.github}/repos/${ref.owner}/${ref.repo}`, |
136 | 136 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
137 | 137 | REPO_META_TTL, |
138 | 138 | ) |
@@ -254,7 +254,7 @@ const bitbucketAdapter: ProviderAdapter = { |
254 | 254 | let res: BitbucketRepoResponse | null = null |
255 | 255 | try { |
256 | 256 | const { data } = await cachedFetch<BitbucketRepoResponse>( |
257 | | - `https://api.bitbucket.org/2.0/repositories/${ref.owner}/${ref.repo}`, |
| 257 | + `${GIT_PROVIDER_API_ORIGINS.bitbucket}/2.0/repositories/${ref.owner}/${ref.repo}`, |
258 | 258 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
259 | 259 | REPO_META_TTL, |
260 | 260 | ) |
@@ -312,7 +312,7 @@ const codebergAdapter: ProviderAdapter = { |
312 | 312 | let res: GiteaRepoResponse | null = null |
313 | 313 | try { |
314 | 314 | const { data } = await cachedFetch<GiteaRepoResponse>( |
315 | | - `https://codeberg.org/api/v1/repos/${ref.owner}/${ref.repo}`, |
| 315 | + `${GIT_PROVIDER_API_ORIGINS.codeberg}/api/v1/repos/${ref.owner}/${ref.repo}`, |
316 | 316 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
317 | 317 | REPO_META_TTL, |
318 | 318 | ) |
@@ -370,7 +370,7 @@ const giteeAdapter: ProviderAdapter = { |
370 | 370 | let res: GiteeRepoResponse | null = null |
371 | 371 | try { |
372 | 372 | const { data } = await cachedFetch<GiteeRepoResponse>( |
373 | | - `https://gitee.com/api/v5/repos/${ref.owner}/${ref.repo}`, |
| 373 | + `${GIT_PROVIDER_API_ORIGINS.gitee}/api/v5/repos/${ref.owner}/${ref.repo}`, |
374 | 374 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
375 | 375 | REPO_META_TTL, |
376 | 376 | ) |
@@ -623,7 +623,7 @@ const radicleAdapter: ProviderAdapter = { |
623 | 623 | let res: RadicleProjectResponse | null = null |
624 | 624 | try { |
625 | 625 | const { data } = await cachedFetch<RadicleProjectResponse>( |
626 | | - `https://seed.radicle.at/api/v1/projects/${ref.repo}`, |
| 626 | + `${GIT_PROVIDER_API_ORIGINS.radicle}/api/v1/projects/${ref.repo}`, |
627 | 627 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
628 | 628 | REPO_META_TTL, |
629 | 629 | ) |
|
0 commit comments