Skip to content

Commit

Permalink
Add more JS Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rich committed Sep 13, 2024
1 parent 6cb8108 commit c07da47
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
12 changes: 12 additions & 0 deletions utils/githubApi/fetchAllRepos.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import {
getOpenPRsForRepo,
} from "../renovate/dependencyDashboard.js";

/**
* Fetches all repos from the GitHub API.
* Each repo is enriched with data fetched through further API calls
* @returns {Promise<StoredRepo[]>}
*/
const fetchAllRepos = async () => {
const repos = [];

Expand All @@ -33,10 +38,17 @@ const fetchAllRepos = async () => {
return repos;
};

/**
* Fetches installation data for the app from the GitHub API
* @returns {Object}
*/
const installationOctokit = await OctokitApp.app.octokit.request(
"GET /app/installations"
);

/**
* Saves all repos to a JSON file
*/
const saveAllRepos = async () => {
console.info("Fetching all repos...");
const repos = await fetchAllRepos();
Expand Down
13 changes: 12 additions & 1 deletion utils/githubApi/fetchOpenPrs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
export const getOpenPRsForRepo = ({ octokit, repository }) => {
/**
* Requests the open PRs for a given repository
* @param {any} {octokit
* @param {any} repository}
* @returns {Promise<number>}
*/
export const getOpenPRsForRepo = async ({ octokit, repository }) => {
return octokit.request(repository.pulls_url).then(handlePrsApiResponse);
};

/**
* Returns the length of the PRs array or 0 if there are no PRs
* @param {any} {data}
* @returns {number}
*/
export const handlePrsApiResponse = ({ data }) => data?.length || 0;

0 comments on commit c07da47

Please sign in to comment.