mirror of
https://github.com/badges/shields.git
synced 2025-04-18 19:44:04 +03:00
migrate [MozillaObservatory] to /scan endpoint (#10491)
This commit is contained in:
parent
ffd0903878
commit
b0d9cb0894
@ -2,12 +2,10 @@ import Joi from 'joi'
|
||||
import { BaseJsonService, pathParam } from '../index.js'
|
||||
|
||||
const schema = Joi.object({
|
||||
scan: Joi.object({
|
||||
grade: Joi.string()
|
||||
.regex(/^[ABCDEF][+-]?$/)
|
||||
.required(),
|
||||
score: Joi.number().integer().min(0).max(200).required(),
|
||||
}).required(),
|
||||
grade: Joi.string()
|
||||
.regex(/^[ABCDEF][+-]?$/)
|
||||
.required(),
|
||||
score: Joi.number().integer().min(0).max(200).required(),
|
||||
}).required()
|
||||
|
||||
const description = `
|
||||
@ -69,15 +67,16 @@ export default class MozillaObservatory extends BaseJsonService {
|
||||
async fetch({ host }) {
|
||||
return this._requestJson({
|
||||
schema,
|
||||
url: 'https://observatory-api.mdn.mozilla.net/api/v2/analyze',
|
||||
url: 'https://observatory-api.mdn.mozilla.net/api/v2/scan',
|
||||
options: {
|
||||
method: 'POST',
|
||||
searchParams: { host },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async handle({ format, host }) {
|
||||
const { scan } = await this.fetch({ host })
|
||||
const scan = await this.fetch({ host })
|
||||
return this.constructor.render({
|
||||
format,
|
||||
grade: scan.grade,
|
||||
|
Loading…
x
Reference in New Issue
Block a user