Skip to content

Commit a62c555

Browse files
committed
config update
1 parent fbdaf76 commit a62c555

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

scripts/fetch-github-data.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import fs from 'fs';
1111
import path from 'path';
1212
import { fileURLToPath } from 'url';
1313
import fetch from 'node-fetch';
14-
import dotenv from 'dotenv';
14+
import * as dotenv from 'dotenv';
1515
import config from '../src/config.js';
1616

1717
// Load environment variables
18-
dotenv.config();
19-
20-
// Constants
2118
const __filename = fileURLToPath(import.meta.url);
2219
const __dirname = path.dirname(__filename);
20+
dotenv.config({ path: path.resolve(__dirname, '../.env') });
21+
22+
// Constants
2323
const OUTPUT_PATH = path.join(__dirname, '../public/projects.json');
2424

2525
// GitHub API URLs
@@ -78,20 +78,23 @@ async function getTopRepositories(org, topic, limit = 3) {
7878
try {
7979
while (true) {
8080
const params = new URLSearchParams({
81-
'q': `org:${org} topic:${topic}`,
81+
'q': `org:${org} topic:"${topic}"`,
82+
'sort': 'stars',
83+
'order': 'desc',
8284
'per_page': '100',
8385
'page': page.toString()
8486
});
8587

8688
const headers = {
8789
'Accept': 'application/vnd.github.v3+json',
88-
'Authorization': `token ${GITHUB_TOKEN}`
90+
'Authorization': `Bearer ${GITHUB_TOKEN}`
8991
};
9092

9193
const response = await fetch(`${GITHUB_API_SEARCH_URL}?${params}`, { headers });
9294

9395
if (!response.ok) {
94-
throw new Error(`HTTP error! Status: ${response.status}`);
96+
const errorData = await response.json();
97+
throw new Error(`HTTP error! Status: ${response.status}, Message: ${JSON.stringify(errorData)}`);
9598
}
9699

97100
const data = await response.json();

0 commit comments

Comments
 (0)