Files
shields/services/archlinux/archlinux.service.js
chris48s b2f47a3303 migrate examples to openApi part 2; affects [archlinux bitcomponents bountysource cdnjs chrome clearlydefined clojars cocoapods coincap] (#9428)
* convert an example that doesn't matter

* migrate some services from examples to openApi

* improve and de-dupe service titles

* revert changes to codefactor
2023-08-08 23:57:47 +00:00

52 lines
1.3 KiB
JavaScript

import Joi from 'joi'
import { renderVersionBadge } from '../version.js'
import { BaseJsonService, pathParams } from '../index.js'
const schema = Joi.object({
pkgver: Joi.string().required(),
}).required()
export default class ArchLinux extends BaseJsonService {
static category = 'version'
static route = {
base: 'archlinux/v',
pattern: ':repository/:architecture/:packageName',
}
static openApi = {
'/archlinux/v/{repository}/{architecture}/{packageName}': {
get: {
summary: 'Arch Linux package',
parameters: pathParams(
{
name: 'repository',
example: 'core',
},
{
name: 'architecture',
example: 'x86_64',
},
{
name: 'packageName',
example: 'pacman',
},
),
},
},
}
static defaultBadgeData = { label: 'arch linux' }
async handle({ repository, architecture, packageName }) {
const data = await this._requestJson({
schema,
url: `https://www.archlinux.org/packages/${encodeURIComponent(
repository,
)}/${encodeURIComponent(architecture)}/${encodeURIComponent(
packageName,
)}/json/`,
})
return renderVersionBadge({ version: data.pkgver })
}
}