11import { GitHubIssue } from '@/types/quickWins' ;
22
3+ // GitHub API response types
4+ interface GitHubIssueResponse {
5+ id : number ;
6+ title : string ;
7+ repository_url : string ;
8+ html_url : string ;
9+ labels : Array < {
10+ name : string ;
11+ color : string ;
12+ } > ;
13+ created_at : string ;
14+ updated_at : string ;
15+ user : {
16+ login : string ;
17+ avatar_url : string ;
18+ } ;
19+ comments : number ;
20+ state : 'open' | 'closed' ;
21+ assignee ?: {
22+ login : string ;
23+ avatar_url : string ;
24+ } | null ;
25+ }
26+
27+ interface GitHubRepoResponse {
28+ full_name : string ;
29+ language : string | null ;
30+ stargazers_count : number ;
31+ }
32+
33+ interface GitHubLabel {
34+ name : string ;
35+ color : string ;
36+ }
37+
338const GITHUB_API_URL = 'https://api.github.com' ;
439
540const CACHE_DURATION = 1000 * 60 * 60 * 12 ;
@@ -34,35 +69,35 @@ async function fetchIssuesFromGitHub({
3469 }
3570 const res = await fetch ( url , { headers } ) ;
3671 if ( ! res . ok ) throw new Error ( 'GitHub API error' ) ;
37- const data = await res . json ( ) ;
72+ const data : GitHubIssueResponse [ ] = await res . json ( ) ;
3873 // Her issue için kendi repository'sinden language ve stars bilgisini çek
39- const issues = await Promise . all ( data . map ( async ( issue : any ) => {
40- let repoData : any = { } ;
74+ const issues = await Promise . all ( data . map ( async ( issue : GitHubIssueResponse ) => {
75+ let repoData : GitHubRepoResponse = { } as GitHubRepoResponse ;
4176 try {
4277 const repoRes = await fetch ( issue . repository_url , { headers } ) ;
4378 if ( repoRes . ok ) {
4479 repoData = await repoRes . json ( ) ;
4580 }
46- } catch ( e ) {
47- repoData = { } ;
81+ } catch {
82+ repoData = { } as GitHubRepoResponse ;
4883 }
4984 return {
5085 id : issue . id ,
5186 title : issue . title ,
5287 repository : repoData . full_name || `${ owner } /${ repo } ` ,
5388 repositoryUrl : issue . repository_url . replace ( 'api.github.com/repos' , 'github.com' ) ,
5489 url : issue . html_url ,
55- labels : issue . labels . map ( ( l : any ) => ( { name : l . name , color : l . color } ) ) ,
90+ labels : issue . labels . map ( ( l : GitHubLabel ) => ( { name : l . name , color : l . color } ) ) ,
5691 created_at : issue . created_at ,
5792 updated_at : issue . updated_at ,
5893 difficulty :
59- issue . labels . some ( ( l : any ) => l . name . toLowerCase ( ) . includes ( 'good first issue' ) )
60- ? 'good'
61- : issue . labels . some ( ( l : any ) => l . name . toLowerCase ( ) . includes ( 'easy' ) )
62- ? 'easy'
63- : issue . labels . some ( ( l : any ) => l . name . toLowerCase ( ) . includes ( 'medium' ) )
64- ? 'medium'
65- : undefined ,
94+ issue . labels . some ( ( l : GitHubLabel ) => l . name . toLowerCase ( ) . includes ( 'good first issue' ) )
95+ ? 'easy' as const
96+ : issue . labels . some ( ( l : GitHubLabel ) => l . name . toLowerCase ( ) . includes ( 'easy' ) )
97+ ? 'easy' as const
98+ : issue . labels . some ( ( l : GitHubLabel ) => l . name . toLowerCase ( ) . includes ( 'medium' ) )
99+ ? 'medium' as const
100+ : 'medium' as const , // Default to medium instead of undefined
66101 language : repoData . language || 'unknown' ,
67102 stars : repoData . stargazers_count || 0 ,
68103 author : {
@@ -72,7 +107,7 @@ async function fetchIssuesFromGitHub({
72107 comments : issue . comments ,
73108 state : issue . state ,
74109 assignee : issue . assignee ,
75- priority : 'medium' ,
110+ priority : 'medium' as const ,
76111 } ;
77112 } ) ) ;
78113 issuesCache [ cacheKey ] = { timestamp : now , data : issues } ;
0 commit comments