Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 94635fe

Browse files
author
GitHub Actions
committed
feat: reduce json output size
1 parent 5b36813 commit 94635fe

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

‎src/helpers.ts‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import GithubApi from './api';
99
import link from './link';
1010
import git from './git';
1111

12-
import type { PaginationLink, ApiGetStarResponse, Stars } from './types';
12+
import type { PaginationLink, ApiGetStarResponse, Stars, Star } from './types';
1313

1414
export const REPO_USERNAME = process.env.GITHUB_REPOSITORY?.split('/')[0];
1515
export const API_STARRED_URL = `${process.env.GITHUB_API_URL}/users/${REPO_USERNAME}/starred`;
@@ -65,9 +65,37 @@ async function* paginateStars(url: string): AsyncGenerator<Stars> {
6565
export async function apiGetStar(
6666
url: string = API_STARRED_URL
6767
): Promise<ApiGetStarResponse> {
68-
let data: Stars[] = [];
68+
const data: Partial<Star>[] = [];
6969
for await (const stars of paginateStars(url)) {
70-
data = data.concat(stars);
70+
for (const star of stars) {
71+
data.push({
72+
id: star.id,
73+
node_id: star.node_id,
74+
name: star.name,
75+
full_name: star.full_name,
76+
owner: {
77+
login: star?.owner?.login,
78+
id: star?.owner?.id,
79+
avatar_url: star?.owner?.avatar_url,
80+
url: star?.owner?.url,
81+
html_url: star?.owner?.html_url,
82+
},
83+
html_url: star.html_url,
84+
description: star.description,
85+
url: star.url,
86+
languages_url: star.languages_url,
87+
created_at: star.created_at,
88+
updated_at: star.updated_at,
89+
git_url: star.git_url,
90+
ssh_url: star.ssh_url,
91+
clone_url: star.clone_url,
92+
homepage: star.homepage,
93+
stargazers_count: star.stargazers_count,
94+
watchers_count: star.watchers_count,
95+
language: star.language,
96+
topics: star.topics,
97+
} as Partial<Star>);
98+
}
7199
}
72100
return (data as unknown) as Stars;
73101
}

0 commit comments

Comments
 (0)