File tree Expand file tree Collapse file tree 1 file changed +43
-2
lines changed Expand file tree Collapse file tree 1 file changed +43
-2
lines changed Original file line number Diff line number Diff line change 126
126
async function getSqliteFiles () {
127
127
const apiUrl =
128
128
" https://api.github.com/repos/CNAG-Biomedical-Informatics/cbi-datahub/contents/sqlite" ;
129
+
130
+ console .log (" Fetching SQLite files from:" , apiUrl);
129
131
try {
130
132
const res = await fetch (apiUrl);
131
- if (! res .ok ) return [];
133
+
134
+ // Check for GitHub rate limiting
135
+ const remaining = res .headers .get (" X-RateLimit-Remaining" );
136
+ const reset = res .headers .get (" X-RateLimit-Reset" );
137
+ const resetDate = reset
138
+ ? new Date (parseInt (reset, 10 ) * 1000 ).toLocaleString ()
139
+ : " unknown" ;
140
+ console .log (
141
+ ` GitHub API rate limit: ${ remaining} remaining, resets at ${ resetDate} `
142
+ );
143
+ if (res .status === 403 && remaining === " 0" ) {
144
+ const resetDate = reset ? new Date (parseInt (reset, 10 ) * 1000 ) : null ;
145
+ console .error (
146
+ ` GitHub API rate limit exceeded. ${
147
+ resetDate
148
+ ? ` Rate limit resets at ${ resetDate .toLocaleString ()} `
149
+ : " "
150
+ } `
151
+ );
152
+ return [];
153
+ }
154
+
155
+ if (! res .ok ) {
156
+ console .error (` GitHub API returned status ${ res .status } ` );
157
+ return [
158
+ {
159
+ name: " omim.db" ,
160
+ type: " file" ,
161
+ download_url:
162
+ " https://raw.githubusercontent.com/CNAG-Biomedical-Informatics/cbi-datahub/main/sqlite/omim.db" ,
163
+ },
164
+ {
165
+ name: " tcga.db" ,
166
+ type: " file" ,
167
+ download_url:
168
+ " https://raw.githubusercontent.com/CNAG-Biomedical-Informatics/cbi-datahub/main/sqlite/tcga.db" ,
169
+ },
170
+ ];
171
+ }
172
+
132
173
const data = await res .json ();
133
174
return data
134
175
.filter (
143
184
` https://raw.githubusercontent.com/CNAG-Biomedical-Informatics/cbi-datahub/main/sqlite/${ item .name } ` ,
144
185
}));
145
186
} catch (e) {
146
- console .error (e);
187
+ console .error (" Error fetching SQLite files: " , e);
147
188
return [];
148
189
}
149
190
}
You can’t perform that action at this time.
0 commit comments