Files
shields/services/ore/ore-downloads.service.js
Caleb Cartwright 8fcde9de85 refactor: use renderDownloadsBadge helper in remaining classes (#7211)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-10-31 16:10:05 +00:00

29 lines
713 B
JavaScript

import { renderDownloadsBadge } from '../downloads.js'
import { BaseOreService, documentation, keywords } from './ore-base.js'
export default class OreDownloads extends BaseOreService {
static category = 'downloads'
static route = {
base: 'ore/dt',
pattern: ':pluginId',
}
static examples = [
{
title: 'Ore Downloads',
namedParams: { pluginId: 'nucleus' },
staticPreview: renderDownloadsBadge({ downloads: 560891 }),
documentation,
keywords,
},
]
static defaultBadgeData = { label: 'downloads' }
async handle({ pluginId }) {
const { stats } = await this.fetch({ pluginId })
return renderDownloadsBadge({ downloads: stats.downloads })
}
}