Files
shields/services/ore/ore-stars.service.js
Bryan Kok a363ea80b9 Add Downloads, Category, License, Sponge Versions, Stars, and Version badges for [Ore], an API platform for Sponge Minecraft plugins (#5757)
* Add Downloads, Category, License, Sponge Versions, Stars, and Version badges for Ore, an API platform for Sponge Minecraft plugins

* Update services/ore/ore-downloads.service.js

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>

* Replace mocked e2e tests with unit tests, fix schema and add test case for Ore License

* Simplify single case forCases

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-11-13 05:12:00 +00:00

43 lines
832 B
JavaScript

'use strict'
const { metric } = require('../text-formatters')
const { BaseOreService, documentation, keywords } = require('./ore-base')
module.exports = class OreStars extends BaseOreService {
static category = 'rating'
static route = {
base: 'ore/stars',
pattern: ':pluginId',
}
static examples = [
{
title: 'Ore Stars',
namedParams: {
pluginId: 'nucleus',
},
staticPreview: this.render({ stars: 1000 }),
documentation,
keywords,
},
]
static defaultBadgeData = {
label: 'stars',
color: 'blue',
}
static render({ stars }) {
return {
message: metric(stars),
}
}
async handle({ pluginId }) {
const { stats } = await this.fetch({ pluginId })
const { stars } = stats
return this.constructor.render({ stars })
}
}