Files
shields/services/modrinth/modrinth-base.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

40 lines
1.1 KiB
JavaScript

import Joi from 'joi'
import { BaseJsonService } from '../index.js'
import { nonNegativeInteger } from '../validators.js'
const projectSchema = Joi.object({
downloads: nonNegativeInteger,
followers: nonNegativeInteger,
}).required()
const versionSchema = Joi.array()
.items(
Joi.object({
version_number: Joi.string().required(),
game_versions: Joi.array().items(Joi.string()).min(1).required(),
}).required(),
)
.required()
const description =
"<p>You can use your project slug, or the project ID. The ID can be found in the 'Technical information' section of your Modrinth page.</p>"
class BaseModrinthService extends BaseJsonService {
async fetchVersions({ projectId }) {
const bruh = {
schema: versionSchema,
url: `https://api.modrinth.com/v2/project/${projectId}/version`,
}
return this._requestJson(bruh)
}
async fetchProject({ projectId }) {
return this._requestJson({
schema: projectSchema,
url: `https://api.modrinth.com/v2/project/${projectId}`,
})
}
}
export { BaseModrinthService, description }