Skip to content

Commit 725531f

Browse files
committed
refactor: npms api constant
1 parent 95c04c0 commit 725531f

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

server/api/registry/badge/[type]/[...pkg].get.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import * as v from 'valibot'
22
import { createError, getRouterParam, getQuery, setHeader } from 'h3'
33
import { PackageRouteParamsSchema } from '#shared/schemas/package'
4-
import { CACHE_MAX_AGE_ONE_HOUR, ERROR_NPM_FETCH_FAILED } from '#shared/utils/constants'
4+
import { CACHE_MAX_AGE_ONE_HOUR, ERROR_NPM_FETCH_FAILED, NPMS_API } from '#shared/utils/constants'
55
import { fetchNpmPackage } from '#server/utils/npm'
66
import { assertValidPackageName } from '#shared/utils/npm'
77
import { handleApiError } from '#server/utils/error-handler'
88

99
const NPM_DOWNLOADS_API = 'https://api.npmjs.org/downloads/point'
1010
const OSV_QUERY_API = 'https://api.osv.dev/v1/query'
1111
const BUNDLEPHOBIA_API = 'https://bundlephobia.com/api/size'
12-
const NPMS_API = 'https://api.npms.io/v2/package'
1312

1413
const QUERY_SCHEMA = v.object({
1514
color: v.optional(v.string()),

server/api/registry/score/[...pkg].get.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import * as v from 'valibot'
22
import { PackageRouteParamsSchema } from '#shared/schemas/package'
3-
import { CACHE_MAX_AGE_ONE_HOUR } from '#shared/utils/constants'
4-
5-
const NPMS_API = 'https://api.npms.io/v2/package'
3+
import { CACHE_MAX_AGE_ONE_HOUR, NPMS_API } from '#shared/utils/constants'
64

75
export interface NpmsScore {
86
final: number

shared/utils/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const NPMX_SITE = 'https://npmx.dev'
1212
export const BLUESKY_API = 'https://public.api.bsky.app/xrpc/'
1313
export const BLUESKY_COMMENTS_REQUEST = '/api/atproto/bluesky-comments'
1414
export const NPM_REGISTRY = 'https://registry.npmjs.org'
15+
export const NPMS_API = 'https://api.npms.io/v2/package'
1516
export const ERROR_PACKAGE_ANALYSIS_FAILED = 'Failed to analyze package.'
1617
export const ERROR_PACKAGE_VERSION_AND_FILE_FAILED = 'Version and file path are required.'
1718
export const ERROR_PACKAGE_REQUIREMENTS_FAILED =

0 commit comments

Comments
 (0)