Skip to content

Commit 82c1f46

Browse files
build(travis): fix GitHub rate limiting (obs-websocket-community-projects#157)
Without authentication, GitHub uses simple IP-based ratelimiting with an extremely low limit. This makes it effectively impossible to use on a CI platform such as Travis. Authenticated requests get a far higher rate limit, and are not IP-based.
1 parent b25d727 commit 82c1f46

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.travis/build-types.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,19 @@ interface OBSStatsType {
7878
const DOTS_REGEX = /\./g;
7979
const outFile = path.join(__dirname, '../types/index.d.ts');
8080
async function getLatestComments() {
81-
const latestReleaseResponse = await got('https://api.github.com/repos/Palakis/obs-websocket/releases/latest', {json: true});
81+
const headers = {
82+
Authorization: `token ${process.env.GH_TOKEN}`
83+
};
84+
85+
const latestReleaseResponse = await got('https://api.github.com/repos/Palakis/obs-websocket/releases/latest', {
86+
json: true,
87+
headers
88+
});
8289
const latestReleaseTag = latestReleaseResponse.body.tag_name;
83-
const commentsResponse = await got(`https://raw.githubusercontent.com/Palakis/obs-websocket/${latestReleaseTag}/docs/generated/comments.json`, {json: true});
90+
const commentsResponse = await got(`https://raw.githubusercontent.com/Palakis/obs-websocket/${latestReleaseTag}/docs/generated/comments.json`, {
91+
json: true,
92+
headers
93+
});
8494
return commentsResponse.body;
8595
}
8696

0 commit comments

Comments
 (0)