diff --git a/api/status/pat-info.js b/api/status/pat-info.js index 69d869ea2553e..1f17bf65aadb9 100644 --- a/api/status/pat-info.js +++ b/api/status/pat-info.js @@ -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} 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} 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} 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} The response. */ export default async (_, res) => { res.setHeader("Content-Type", "application/json");