|
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 |
@@ -134,7 +134,7 @@ const githubAdapter: ProviderAdapter = { |
134 | 134 | let res: UnghRepoResponse | null = null |
135 | 135 | try { |
136 | 136 | const { data } = await cachedFetch<UnghRepoResponse>( |
137 | | - `https://ungh.cc/repos/${ref.owner}/${ref.repo}`, |
| 137 | + `${GIT_PROVIDER_API_ORIGINS.github}/repos/${ref.owner}/${ref.repo}`, |
138 | 138 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
139 | 139 | UNGH_REPO_META_TTL, |
140 | 140 | ) |
@@ -256,7 +256,7 @@ const bitbucketAdapter: ProviderAdapter = { |
256 | 256 | let res: BitbucketRepoResponse | null = null |
257 | 257 | try { |
258 | 258 | const { data } = await cachedFetch<BitbucketRepoResponse>( |
259 | | - `https://api.bitbucket.org/2.0/repositories/${ref.owner}/${ref.repo}`, |
| 259 | + `${GIT_PROVIDER_API_ORIGINS.bitbucket}/2.0/repositories/${ref.owner}/${ref.repo}`, |
260 | 260 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
261 | 261 | REPO_META_TTL, |
262 | 262 | ) |
@@ -314,7 +314,7 @@ const codebergAdapter: ProviderAdapter = { |
314 | 314 | let res: GiteaRepoResponse | null = null |
315 | 315 | try { |
316 | 316 | const { data } = await cachedFetch<GiteaRepoResponse>( |
317 | | - `https://codeberg.org/api/v1/repos/${ref.owner}/${ref.repo}`, |
| 317 | + `${GIT_PROVIDER_API_ORIGINS.codeberg}/api/v1/repos/${ref.owner}/${ref.repo}`, |
318 | 318 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
319 | 319 | REPO_META_TTL, |
320 | 320 | ) |
@@ -372,7 +372,7 @@ const giteeAdapter: ProviderAdapter = { |
372 | 372 | let res: GiteeRepoResponse | null = null |
373 | 373 | try { |
374 | 374 | const { data } = await cachedFetch<GiteeRepoResponse>( |
375 | | - `https://gitee.com/api/v5/repos/${ref.owner}/${ref.repo}`, |
| 375 | + `${GIT_PROVIDER_API_ORIGINS.gitee}/api/v5/repos/${ref.owner}/${ref.repo}`, |
376 | 376 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
377 | 377 | REPO_META_TTL, |
378 | 378 | ) |
@@ -625,7 +625,7 @@ const radicleAdapter: ProviderAdapter = { |
625 | 625 | let res: RadicleProjectResponse | null = null |
626 | 626 | try { |
627 | 627 | const { data } = await cachedFetch<RadicleProjectResponse>( |
628 | | - `https://seed.radicle.at/api/v1/projects/${ref.repo}`, |
| 628 | + `${GIT_PROVIDER_API_ORIGINS.radicle}/api/v1/projects/${ref.repo}`, |
629 | 629 | { headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }, |
630 | 630 | REPO_META_TTL, |
631 | 631 | ) |
|
0 commit comments