Refactor: Status PAT info endpoint: Resolve jsdoc eslint errors (#3045)

This commit is contained in:
Alexandr Garbuzov
2023-08-07 00:09:21 +03:00
committed by GitHub
parent 8780cc24ae
commit ed84840b97
+21 -2
View File
@@ -8,11 +8,17 @@
import { logger, request, dateDiff } 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(
@@ -36,8 +42,17 @@ const getAllPATs = () => {
return Object.keys(process.env).filter((key) => /PAT_\d*$/.exec(key));
};
/**
* @typedef {(variables: AxiosRequestHeaders, token: string) => Promise<AxiosResponse>} Fetcher The fetcher function.
* @typedef {{validPATs: string[], expiredPATs: string[], exhaustedPATs: string[], suspendedPATs: string[], errorPATs: string[], details: any}} PATInfo The PAT info.
*/
/**
* Check whether any of the PATs is expired.
*
* @param {Fetcher} fetcher The fetcher function.
* @param {AxiosRequestHeaders} variables Fetcher variables.
* @returns {Promise<PATInfo>} The response.
*/
const getPATInfo = async (fetcher, variables) => {
const details = {};
@@ -117,6 +132,10 @@ const getPATInfo = async (fetcher, variables) => {
/**
* Cloud function that returns information about the used PATs.
*
* @param {any} _ The request.
* @param {any} res The response.
* @returns {Promise<void>} The response.
*/
export default async (_, res) => {
res.setHeader("Content-Type", "application/json");