I find having these in a consistent order makes the services much faster to read. This is the order I’ve generally been using: 1. Category 2. Route 3. Examples 4. Rendering 5. Other helpers (`fetch()`, `transform()`) 6. `handle()`
33 lines
733 B
JavaScript
33 lines
733 B
JavaScript
'use strict'
|
|
|
|
const Joi = require('joi')
|
|
const { BaseJsonService } = require('..')
|
|
const { nonNegativeInteger } = require('../validators')
|
|
|
|
const condaSchema = Joi.object({
|
|
latest_version: Joi.string().required(),
|
|
conda_platforms: Joi.array()
|
|
.items(Joi.string())
|
|
.required(),
|
|
files: Joi.array()
|
|
.items(
|
|
Joi.object({
|
|
ndownloads: nonNegativeInteger,
|
|
})
|
|
)
|
|
.required(),
|
|
}).required()
|
|
|
|
module.exports = class BaseCondaService extends BaseJsonService {
|
|
static get defaultBadgeData() {
|
|
return { label: 'conda' }
|
|
}
|
|
|
|
async fetch({ channel, pkg }) {
|
|
return this._requestJson({
|
|
schema: condaSchema,
|
|
url: `https://api.anaconda.org/package/${channel}/${pkg}`,
|
|
})
|
|
}
|
|
}
|