1
0
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:
chris48s 2024-09-07 18:56:45 +01:00 committed by GitHub
parent ffd0903878
commit b0d9cb0894
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,