Skip to content

refactor: add githubFetch helper to centralize GitHub API fetch logic (#959)#1285

Open
mallya-m wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
mallya-m:refactor/github-fetch-wrapper-959
Open

refactor: add githubFetch helper to centralize GitHub API fetch logic (#959)#1285
mallya-m wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
mallya-m:refactor/github-fetch-wrapper-959

Conversation

@mallya-m
Copy link
Copy Markdown
Contributor

Summary

Closes #959

Creates src/lib/github-fetch.ts with typed helpers to eliminate the repeated ~10-line GitHub API fetch pattern across 8+ metric routes.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup

Changes Made

  • Added githubFetch<T>() — typed REST fetch with Authorization header, Accept header, ok-check, and 403/429 rate limit handling
  • Added githubGraphQL<T>() — typed GraphQL fetch helper
  • Added GitHubRateLimitError and GitHubApiError typed error classes
  • Re-exported GITHUB_API constant for convenience

How to Test

  1. Import githubFetch in any metric route instead of raw fetch
  2. Run npm run type-check — no errors
  3. No behavior change — same error handling, same response types

Checklist

  • Linked issue in summary
  • No TypeScript errors
  • Self-reviewed the diff
  • No behavior change

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

@mallya-m is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:refactor GSSoC type bonus: refactor (+10 pts) labels May 27, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@mallya-m
Copy link
Copy Markdown
Contributor Author

@Priyanshu-byte-coder PR is ready — created src/lib/github-fetch.ts with typed githubFetch<T>() and githubGraphQL<T>() helpers plus typed error classes.

Could you please add:

  • gssoc:approved
  • level:intermediate
  • type:feature type:refactor

Ready for merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:refactor GSSoC type bonus: refactor (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] Extract common GitHub API fetch wrapper to reduce duplication across metric routes

1 participant