From 8780cc24aea181b2add63fa41d7803f8d7d8d839 Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov Date: Mon, 7 Aug 2023 00:08:47 +0300 Subject: [PATCH] Refactor: Status up endpoint: Resolve jsdoc eslint errors (#3046) --- api/status/up.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/api/status/up.js b/api/status/up.js index 678a20b0b5c14..786ac0b335a79 100644 --- a/api/status/up.js +++ b/api/status/up.js @@ -10,11 +10,17 @@ import { logger, request } from "../../src/common/utils.js"; export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 5 minutes +/** + * @typedef {import('axios').AxiosRequestHeaders} AxiosRequestHeaders Axios request headers. + * @typedef {import('axios').AxiosResponse} AxiosResponse Axios response. + */ + /** * Simple uptime check fetcher for the PATs. * - * @param {import('axios').AxiosRequestHeaders} variables - * @param {string} token + * @param {AxiosRequestHeaders} variables Fetcher variables. + * @param {string} token GitHub token. + * @returns {Promise} The response. */ const uptimeFetcher = (variables, token) => { return request( @@ -34,11 +40,21 @@ const uptimeFetcher = (variables, token) => { ); }; +/** + * @typedef {{ + * schemaVersion: number; + * label: string; + * message: "up" | "down"; + * color: "brightgreen" | "red"; + * isError: boolean + * }} ShieldsResponse Shields.io response object. + */ + /** * Creates Json response that can be used for shields.io dynamic card generation. * - * @param {*} up Whether the PATs are up or not. - * @returns Dynamic shields.io JSON response object. + * @param {boolean} up Whether the PATs are up or not. + * @returns {ShieldsResponse} Dynamic shields.io JSON response object. * * @see https://shields.io/endpoint. */ @@ -59,6 +75,10 @@ const shieldsUptimeBadge = (up) => { /** * Cloud function that returns whether the PATs are still functional. + * + * @param {any} req The request. + * @param {any} res The response. + * @returns {Promise} Nothing. */ export default async (req, res) => { let { type } = req.query;