MCPcopy Create free account
hub / github.com/IsAvaible/AngularModUpdater / GitHub

Class GitHub

src/app/libraries/github/github.ts:24–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22import { RateLimitInfo } from '../RateLimitedApi';
23
24export class GitHub extends BaseApiProvider {
25 protected override apiName = 'GitHub';
26 public githubAPIUrl = 'https://api.github.com';
27 public headers = {
28 Accept: 'application/vnd.github.v3+json',
29 'Content-Type': 'application/json'
30 };
31
32 private http = inject(HttpClient);
33
34 protected override get _rateLimitInfo(): RateLimitInfo {
35 return {
36 limit: 60,
37 remaining: 60,
38 resetTime: new Date(Date.now() + 60 * 60 * 1000) // one hour reset time
39 };
40 }
41
42 /**
43 * Predefined GitHub repository configurations
44 */
45 public static REPO_CONFIGS: GitHubRepoConfig[] = GitHub.createRepoConfigs();
46
47 private static createRepoConfigs(): GitHubRepoConfig[] {
48 let configs: GitHubRepoConfig[] = [];
49
50 const sakuraRyokoConfigs: GitHubRepoConfig[] = [
51 { modName: 'litematica', modrinthPage: 'bEpr0Arc' },
52 { modName: 'malilib', modrinthPage: 'GcWjdA9I' },
53 { modName: 'minihud', modrinthPage: 'UMxybHE8' },
54 { modName: 'tweakeroo', modrinthPage: 't5wuYk45' },
55 { modName: 'itemscroller', modrinthPage: 'JygyCSA4' },
56 { modName: 'servux', modrinthPage: 'zQhsx8KF' }
57 ].map(({ modName, modrinthPage }) => ({
58 owner: 'sakura-ryoko',
59 repo: modName,
60 loader: Loader.fabric,
61 pattern: new RegExp(`^${modName}.*?-.+?-.+?-sakura.\\d+?.jar$`, 'i'),
62 modrinthPage
63 }));
64
65 configs = configs.concat(sakuraRyokoConfigs);
66
67 return configs;
68 }
69
70 /**
71 * Check if error is rate limit related (API-specific implementation)
72 */
73 protected override isRateLimitError(error: any): boolean {
74 return !!((error && error.status === 429) || error.status == 403);
75 }
76
77 /**
78 * Gets releases for a GitHub repository
79 */
80 public getReleases(
81 config: GitHubRepoConfig

Callers

nothing calls this directly

Calls 1

createRepoConfigsMethod · 0.80

Tested by

no test coverage detected