Skip to content
Merged
8 changes: 0 additions & 8 deletions docs/content/2.guide/1.features.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ Make sure to replace `TYPE` with one of the options listed below and `YOUR_PACKA
- **types**: Indicates if TypeScript types are included. :img{src="https://img.shields.io/badge/%233b82f6-3b82f6" class="inline align-middle h-5 w-14"} / :img{src="https://img.shields.io/badge/%2364748b-64748b" class="inline align-middle h-5 w-14"}
- **maintainers**: Displays the total count of package maintainers. :img{src="https://img.shields.io/badge/%2306b6d4-06b6d4" class="inline align-middle h-5 w-14"}
- **deprecated**: Shows if the package is active or deprecated. :img{src="https://img.shields.io/badge/%2322c55e-22c55e" class="inline align-middle h-5 w-14"} / :img{src="https://img.shields.io/badge/%23ef4444-ef4444" class="inline align-middle h-5 w-14"}
- **quality**: NPMS.io quality score based on linting and tests. :img{src="https://img.shields.io/badge/%23a855f7-a855f7" class="inline align-middle h-5 w-14"}
- **popularity**: NPMS.io popularity score based on downloads and stars. :img{src="https://img.shields.io/badge/%2306b6d4-06b6d4" class="inline align-middle h-5 w-14"}
- **maintenance**: NPMS.io maintenance score based on activity. :img{src="https://img.shields.io/badge/%23eab308-eab308" class="inline align-middle h-5 w-14"}
- **score**: The overall NPMS.io combined score. :img{src="https://img.shields.io/badge/%233b82f6-3b82f6" class="inline align-middle h-5 w-14"}
- **name**: Simple badge displaying the package name. :img{src="https://img.shields.io/badge/%2364748b-64748b" class="inline align-middle h-5 w-14"}

#### Examples
Expand All @@ -147,10 +143,6 @@ Make sure to replace `TYPE` with one of the options listed below and `YOUR_PACKA
# Specific Version

[![Open on npmx.dev](https://npmx.dev/api/registry/badge/version/react/v/18.0.0)](https://npmx.dev/package/react)

# Quality Score

[![Open on npmx.dev](https://npmx.dev/api/registry/badge/quality/pinia)](https://npmx.dev/package/pinia)
```

#### Customization Parameters
Expand Down
23 changes: 0 additions & 23 deletions modules/runtime/server/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,6 @@ function getMockForUrl(url: string): MockResult | null {
}
}

// npms.io API - return mock package score data
if (host === 'api.npms.io') {
const packageMatch = decodeURIComponent(pathname).match(/^\/v2\/package\/(.+)$/)
if (packageMatch?.[1]) {
return {
data: {
analyzedAt: new Date().toISOString(),
collected: {
metadata: { name: packageMatch[1] },
},
score: {
final: 0.75,
detail: {
quality: 0.8,
popularity: 0.7,
maintenance: 0.75,
},
},
},
}
}
}

// jsdelivr CDN - return 404 for README files, etc.
if (host === 'cdn.jsdelivr.net') {
// Return null data which will cause a 404 - README files are optional
Expand Down
35 changes: 0 additions & 35 deletions server/api/registry/badge/[type]/[...pkg].get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { handleApiError } from '#server/utils/error-handler'
const NPM_DOWNLOADS_API = 'https://api.npmjs.org/downloads/point'
const OSV_QUERY_API = 'https://api.osv.dev/v1/query'
const BUNDLEPHOBIA_API = 'https://bundlephobia.com/api/size'
const NPMS_API = 'https://api.npms.io/v2/package'

const SafeStringSchema = v.pipe(v.string(), v.regex(/^[^<>"&]*$/, 'Invalid characters'))
const SafeColorSchema = v.pipe(
Expand Down Expand Up @@ -252,16 +251,6 @@ async function fetchDownloads(
}
}

async function fetchNpmsScore(packageName: string) {
try {
const response = await fetch(`${NPMS_API}/${encodeURIComponent(packageName)}`)
const data = await response.json()
return data.score
} catch {
return null
}
}

async function fetchVulnerabilities(packageName: string, version: string): Promise<number> {
try {
const response = await fetch(OSV_QUERY_API, {
Expand Down Expand Up @@ -395,30 +384,6 @@ const badgeStrategies = {
color: isDeprecated ? COLORS.red : COLORS.green,
}
},

'quality': async (pkgData: globalThis.Packument) => {
const score = await fetchNpmsScore(pkgData.name)
const value = score ? `${Math.round(score.detail.quality * 100)}%` : 'unknown'
return { label: 'quality', value, color: COLORS.purple }
},

'popularity': async (pkgData: globalThis.Packument) => {
const score = await fetchNpmsScore(pkgData.name)
const value = score ? `${Math.round(score.detail.popularity * 100)}%` : 'unknown'
return { label: 'popularity', value, color: COLORS.cyan }
},

'maintenance': async (pkgData: globalThis.Packument) => {
const score = await fetchNpmsScore(pkgData.name)
const value = score ? `${Math.round(score.detail.maintenance * 100)}%` : 'unknown'
return { label: 'maintenance', value, color: COLORS.yellow }
},

'score': async (pkgData: globalThis.Packument) => {
const score = await fetchNpmsScore(pkgData.name)
const value = score ? `${Math.round(score.final * 100)}%` : 'unknown'
return { label: 'score', value, color: COLORS.blue }
},
}

const BadgeTypeSchema = v.picklist(Object.keys(badgeStrategies) as [string, ...string[]])
Expand Down
31 changes: 0 additions & 31 deletions test/fixtures/mock-routes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -373,36 +373,6 @@ function matchBundlephobiaApi(urlString) {
return null
}

/**
* @param {string} urlString
* @returns {MockResponse | null}
*/
function matchNpmsApi(urlString) {
const url = new URL(urlString)
const pathname = decodeURIComponent(url.pathname)

const packageMatch = pathname.match(/^\/v2\/package\/(.+)$/)
if (packageMatch && packageMatch[1]) {
const packageName = packageMatch[1]
return json({
analyzedAt: new Date().toISOString(),
collected: {
metadata: { name: packageName },
},
score: {
final: 0.75,
detail: {
quality: 0.8,
popularity: 0.7,
maintenance: 0.75,
},
},
})
}

return null
}

/**
* @param {string} _urlString
* @returns {MockResponse | null}
Expand Down Expand Up @@ -534,7 +504,6 @@ const routes = [
{ name: 'fast-npm-meta', pattern: 'https://npm.antfu.dev/**', match: matchFastNpmMeta },
{ name: 'JSR registry', pattern: 'https://jsr.io/**', match: matchJsrRegistry },
{ name: 'Bundlephobia API', pattern: 'https://bundlephobia.com/**', match: matchBundlephobiaApi },
{ name: 'npms.io API', pattern: 'https://api.npms.io/**', match: matchNpmsApi },
{ name: 'jsdelivr CDN', pattern: 'https://cdn.jsdelivr.net/**', match: matchJsdelivrCdn },
{
name: 'jsdelivr Data API',
Expand Down
Loading