Skip to content

Commit

Permalink
replace experimental API usage with newly available v1 API (#9886)
Browse files Browse the repository at this point in the history
resolves #9837
  • Loading branch information
Lordfirespeed authored Jan 9, 2024
1 parent 79dd749 commit bfcbaea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
23 changes: 1 addition & 22 deletions services/thunderstore/thunderstore-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ import Joi from 'joi'
import { BaseJsonService } from '../index.js'
import { nonNegativeInteger } from '../validators.js'

const packageSchema = Joi.object({
latest: Joi.object({
version_number: Joi.string().required(),
}).required(),
}).required()

const packageMetricsSchema = Joi.object({
downloads: nonNegativeInteger,
rating_score: nonNegativeInteger,
latest_version: Joi.string().required(),
})

const description = `
Expand Down Expand Up @@ -58,22 +53,6 @@ const description = `
*/
class BaseThunderstoreService extends BaseJsonService {
static thunderstoreGreen = '23FFB0'

/**
* Fetches package metadata from the Thunderstore API.
*
* @param {object} pkg - Package specifier
* @param {string} pkg.namespace - the package namespace
* @param {string} pkg.packageName - the package name
* @returns {Promise<object>} - Promise containing validated package information
*/
async fetchPackage({ namespace, packageName }) {
return this._requestJson({
schema: packageSchema,
url: `https://thunderstore.io/api/experimental/package/${namespace}/${packageName}`,
})
}

/**
* Fetches package metrics from the Thunderstore API.
*
Expand Down
7 changes: 4 additions & 3 deletions services/thunderstore/thunderstore-version.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ export default class ThunderstoreVersion extends BaseThunderstoreService {
* @returns {Promise<object>} - Promise containing the rendered badge payload
*/
async handle({ namespace, packageName }) {
const {
latest: { version_number: version },
} = await this.fetchPackage({ namespace, packageName })
const { latest_version: version } = await this.fetchPackageMetrics({
namespace,
packageName,
})
return renderVersionBadge({ version })
}
}

0 comments on commit bfcbaea

Please sign in to comment.