Files
shields/services/ore/ore-category.service.js
chris48s 5d1ddbc3fe migrate examples to openApi part 13; affects [curseforge date fedora hsts modrinth ore] (#9499)
* migrate some services from examples to openApi

* improve and de-dupe service titles

* improve ore description
2023-12-04 12:53:21 +00:00

47 lines
960 B
JavaScript

import { pathParams } from '../index.js'
import { BaseOreService, description } from './ore-base.js'
export default class OreCategory extends BaseOreService {
static category = 'other'
static route = {
base: 'ore/category',
pattern: ':pluginId',
}
static openApi = {
'/ore/category/{pluginId}': {
get: {
summary: 'Ore Category',
description,
parameters: pathParams({
name: 'pluginId',
example: 'nucleus',
}),
},
},
}
static defaultBadgeData = {
label: 'category',
color: 'blue',
}
static render({ category }) {
return {
message: category,
}
}
transform({ data }) {
const category = data.category.replace(/_/g, ' ')
return { category }
}
async handle({ pluginId }) {
const data = await this.fetch({ pluginId })
const { category } = this.transform({ data })
return this.constructor.render({ category })
}
}