* Add [polymart] badges (#7429) * fix misspelling issue * add required to all joi objects * fix not found badge return a valid resource issue * fix misspelling issue * fix invalid resource issue * remove default badge color Co-authored-by: chris48s <chris48s@users.noreply.github.com> * remove version default badge color * change version label to the service name * add renderVersionBadge() method for version rendering * fix method name issue * change version regex * fix code style issue * add renderVersionBadge from version and remove the manually added renderer Co-authored-by: chris48s <chris48s@users.noreply.github.com>
39 lines
914 B
JavaScript
39 lines
914 B
JavaScript
import { NotFound } from '../../core/base-service/errors.js'
|
|
import { renderVersionBadge } from '../version.js'
|
|
import { BasePolymartService, documentation } from './polymart-base.js'
|
|
export default class PolymartLatestVersion extends BasePolymartService {
|
|
static category = 'version'
|
|
|
|
static route = {
|
|
base: 'polymart/version',
|
|
pattern: ':resourceId',
|
|
}
|
|
|
|
static examples = [
|
|
{
|
|
title: 'Polymart Version',
|
|
namedParams: {
|
|
resourceId: '323',
|
|
},
|
|
staticPreview: renderVersionBadge({
|
|
version: 'v1.2.9',
|
|
}),
|
|
documentation,
|
|
},
|
|
]
|
|
|
|
static defaultBadgeData = {
|
|
label: 'polymart',
|
|
}
|
|
|
|
async handle({ resourceId }) {
|
|
const { response } = await this.fetch({ resourceId })
|
|
if (!response.resource) {
|
|
throw new NotFound()
|
|
}
|
|
return renderVersionBadge({
|
|
version: response.resource.updates.latest.version,
|
|
})
|
|
}
|
|
}
|