Files
shields/services/jsdelivr/jsdelivr-base.js
Caleb Cartwright 89410389e0 use downloads renderer in next batch of classes, run [hexpm homebrewdownloads jenkinsplugininstalls jetbrainsdownloads jsdelivr modrinth]] (#7210)
* refactor: use downloads renderer in next batch of classes

* chore: run prettier
2021-10-31 10:55:25 -05:00

29 lines
603 B
JavaScript

import Joi from 'joi'
import { renderDownloadsBadge } from '../downloads.js'
import { BaseJsonService } from '../index.js'
const schema = Joi.object({
total: Joi.number().required(),
}).required()
const periodMap = {
hd: 'day',
hw: 'week',
hm: 'month',
hy: 'year',
}
class BaseJsDelivrService extends BaseJsonService {
static category = 'downloads'
static defaultBadgeData = {
label: 'jsdelivr',
}
static render({ period, hits: downloads }) {
return renderDownloadsBadge({ downloads, interval: periodMap[period] })
}
}
export { schema, periodMap, BaseJsDelivrService }