Skip to content

Commit

Permalink
Refactor: Status up endpoint: Resolve jsdoc eslint errors (anuraghazr…
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 authored Aug 6, 2023
1 parent d2e4ddd commit 8780cc2
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions api/status/up.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<AxiosResponse>} The response.
*/
const uptimeFetcher = (variables, token) => {
return request(
Expand All @@ -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.
*/
Expand All @@ -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<void>} Nothing.
*/
export default async (req, res) => {
let { type } = req.query;
Expand Down

0 comments on commit 8780cc2

Please sign in to comment.