File tree Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,32 @@ const GITHUB_USER_REPO_ENDPOINT = environment.gitHubConfig.GITHUB_USER_REPO_ENDP
99: 'https://api.github.com/users/navneetsharmaui/repos?per_page=100' ;
1010
1111/** @type {import('@sveltejs/kit').RequestHandler } */
12- export async function get ( { query } ) {
12+ export async function get ( {
13+ query,
14+ } : {
15+ query : URLSearchParams ;
16+ } ) : Promise <
17+ | {
18+ status : number ;
19+ headers ?: {
20+ [ key : string ] : string ;
21+ } ;
22+ body ?: {
23+ followers : unknown ;
24+ stars : unknown ;
25+ } ;
26+ }
27+ | {
28+ status : number ;
29+ headers ?: {
30+ [ key : string ] : string ;
31+ } ;
32+ body : {
33+ followers : unknown ;
34+ stars : unknown ;
35+ } ;
36+ }
37+ > {
1338const limit = Number ( query . get ( 'limit' ) ?? 10 ) ;
1439
1540if ( Number . isNaN ( limit ) ) {
@@ -24,8 +49,11 @@ export async function get({ query }) {
2449const user = await githubUser . json ( ) ;
2550const allRespos = await githubUserRepos . json ( ) ;
2651
27- const reposWithoutFork = allRespos . filter ( ( repo ) => ! repo . fork ) ;
28- const stars = reposWithoutFork . reduce ( ( accumulator , repo ) => accumulator + repo [ 'stargazers_count' ] , 0 ) ;
52+ const reposWithoutFork = allRespos . filter ( ( repo : { fork : unknown } ) => ! repo . fork ) ;
53+ const stars = reposWithoutFork . reduce (
54+ ( accumulator : unknown , repo : { [ x : string ] : unknown } ) => `${ accumulator } ${ repo [ 'stargazers_count' ] } ` ,
55+ 0 ,
56+ ) ;
2957return {
3058status : 200 ,
3159headers : {
You can’t perform that action at this time.
0 commit comments