Files
shields/services/pypi/pypi-license.service.js
chris48s 692829f91c migrate examples to openApi part 6; affects [opencollective opm ossf powershell pub pypi reddit repology] (#9462)
* migrate some services from examples to openApi

* improve and de-dupe service titles
2023-08-19 04:33:27 +00:00

33 lines
791 B
JavaScript

import { pathParams } from '../index.js'
import { renderLicenseBadge } from '../licenses.js'
import PypiBase from './pypi-base.js'
import { getLicenses } from './pypi-helpers.js'
export default class PypiLicense extends PypiBase {
static category = 'license'
static route = this.buildRoute('pypi/l')
static openApi = {
'/pypi/l/{packageName}': {
get: {
summary: 'PyPI - License',
parameters: pathParams({
name: 'packageName',
example: 'Django',
}),
},
},
}
static render({ licenses }) {
return renderLicenseBadge({ licenses })
}
async handle({ egg }) {
const packageData = await this.fetch({ egg })
const licenses = getLicenses(packageData)
return this.constructor.render({ licenses })
}
}