* you missed one * remove examples from deprecatedService() I'm not going to replace this with openApi We have zero examples of deprecated services that declare examples * remove examples from redirector() * update test * remove compatibility code for converting examples to openApi * remove all the code for handling examples * remove a few bits of redundant code * improve docs for openApi property * last one, I promise
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import Joi from 'joi'
|
|
import camelcase from 'camelcase'
|
|
import BaseService from './base.js'
|
|
import { isValidCategory } from './categories.js'
|
|
import { Deprecated } from './errors.js'
|
|
import { isValidRoute } from './route.js'
|
|
|
|
const attrSchema = Joi.object({
|
|
route: isValidRoute,
|
|
name: Joi.string(),
|
|
label: Joi.string(),
|
|
category: isValidCategory,
|
|
message: Joi.string(),
|
|
dateAdded: Joi.date().required(),
|
|
}).required()
|
|
|
|
function deprecatedService(attrs) {
|
|
const { route, name, label, category, message } = Joi.attempt(
|
|
attrs,
|
|
attrSchema,
|
|
`Deprecated service for ${attrs.route.base}`,
|
|
)
|
|
|
|
return class DeprecatedService extends BaseService {
|
|
static name = name
|
|
? `Deprecated${name}`
|
|
: `Deprecated${camelcase(route.base.replace(/\//g, '_'), {
|
|
pascalCase: true,
|
|
})}`
|
|
|
|
static category = category
|
|
static isDeprecated = true
|
|
static route = route
|
|
static defaultBadgeData = { label }
|
|
|
|
async handle() {
|
|
throw new Deprecated({ prettyMessage: message })
|
|
}
|
|
}
|
|
}
|
|
|
|
export default deprecatedService
|