Continue to implement #2698: - Add `core/base-service/index.js` (but hold off on moving the things it imports) - Add shortcuts in `services/index.js` for Base*Service, errors, and deprecatedService. This file will be streamlined later to avoid cluttering it with rarely used bits. - Apply consistent ordering of imports and use of `module.exports` in testers. - Remove some renaming of imports. - Remove obsolete tests here and there.
24 lines
531 B
JavaScript
24 lines
531 B
JavaScript
'use strict'
|
|
|
|
const Joi = require('joi')
|
|
const { BaseJsonService } = require('..')
|
|
|
|
const schema = Joi.object({
|
|
version: Joi.string().required(),
|
|
license: Joi.array()
|
|
.items(Joi.string())
|
|
.min(1)
|
|
.required(),
|
|
}).required()
|
|
|
|
module.exports = class BaseCpanService extends BaseJsonService {
|
|
async fetch({ packageName }) {
|
|
const url = `https://fastapi.metacpan.org/v1/release/${packageName}`
|
|
return this._requestJson({ schema, url })
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return { label: 'cpan' }
|
|
}
|
|
}
|