Skip to content

Conversation

mukeshdhadhariya
Copy link

@mukeshdhadhariya mukeshdhadhariya commented Oct 11, 2025

Summary

  • Remove client-side token access; accept token via constructor or setAuthToken() (server-side only). Update README with instantiation instructions: new GitHubService(process.env.GITHUB_TOKEN).
  • Add ETag / If-None-Match support and store ETags in cache meta. Conditional GET reduces API usage and avoids hitting rate limits.
  • fetchWithRetry now accepts custom headers and handles 304 Not Modified responses. Cache now stores { data, etags, lastUpdated }.

Why

Exposing tokens in client-side code risks leaking credentials and causing abuse. Using conditional requests via ETag reduces bandwidth and GitHub API rate consumption.

Developer notes

  • Instantiate server-side with: const svc = new GitHubService(process.env.GITHUB_TOKEN);
  • Do not set tokens on window in production.
  • Cache meta now includes ETags (keyed by endpoint) and lastUpdated for freshness checks.
issue #891

Refactor GitHubService to support ETag conditional requests and improve caching. Removed client-side token reading and added methods for managing cached meta data.
Copy link

vercel bot commented Oct 11, 2025

@mukeshdhadhariya is attempting to deploy a commit to the recode Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. The estimated time for response is 5–8 hrs.

In the meantime, please provide all necessary screenshots and make sure you run - npm build run , command and provide a screenshot, a video recording, or an image of the update you made below, which helps speed up the review and assignment. If you have questions, reach out to LinkedIn. Your contributions are highly appreciated!😊

Note: I maintain the repo issue every day twice at 8:00 AM IST and 9:00 PM IST. If your PR goes stale for more than one day, you can tag and comment on this same issue by tagging @sanjay-kv.

We are here to help you on this journey of open source. Consistent 20 contributions are eligible for sponsorship 💰

🎁 check our list of amazing people we sponsored so far: GitHub Sponsorship. ✨

📚Your perks for contribution to this community 👇🏻

  1. Get free Consultation use code recode50 to get free: Mentorship for free.

  2. Get the Ebook for free use code recode at checkout: Data Science cheatsheet for Beginners.

  3. Check out this weekly Newsletter: Sanjay's Newsletter.

If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

@github-actions github-actions bot added hacktoberfest-accepted level 1 10 points recode this is label for leaderboard labels Oct 11, 2025
@mukeshdhadhariya mukeshdhadhariya marked this pull request as ready for review October 11, 2025 17:11
Copy link

vercel bot commented Oct 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
recode-website Ready Ready Preview Comment Oct 12, 2025 3:59am

@sanjay-kv
Copy link
Member

@Adez017 can you cross check this.

@sanjay-kv sanjay-kv requested a review from Copilot October 12, 2025 03:59
@sanjay-kv sanjay-kv added this to the recode:launch 3.0 milestone Oct 12, 2025
@sanjay-kv sanjay-kv moved this to In Progress in @recode-web Oct 12, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the GitHub API service by moving authentication tokens server-side and implementing ETag-based conditional caching to reduce API calls and prevent rate limiting.

  • Removes client-side token access through window.GITHUB_TOKEN and adds constructor/method-based token setting
  • Implements ETag conditional caching with If-None-Match headers to avoid unnecessary API calls
  • Enhances cache structure to store ETags and metadata alongside data

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

signal,
},
);
const url = `${this.BASE_URL}/search/issues?q=org:${this.ORG_NAME}+type:issue`;
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search query changed from repo-specific to org-wide (org:${this.ORG_NAME} instead of repo:${this.ORG_NAME}/Support). This will return all issues across the organization rather than discussions from a specific repository, potentially causing inaccurate discussion counts.

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems a issue.

},
);
// Use per_page=1 to leverage Link header for total pages, if present
const url = `${this.BASE_URL}/repos/${repo.full_name}/contributors?per_page=1&anon=true`;
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding anon=true parameter changes the API behavior to include anonymous contributors. This may affect contributor count accuracy compared to the previous implementation and should be documented or made configurable.

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this one

Comment on lines 511 to 518
const response = await this.fetchWithRetry("https://api.github.com/graphql", {
method: "POST",
headers: {
...this.getHeaders(),
"Content-Type": "application/json",
},
body: JSON.stringify({ query, variables }),
body: { query, variables },
signal,
});
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body should be a JSON string, but it's being passed as an object. The fetchWithRetry method calls JSON.stringify(options.body) only when options.body exists, but this will result in double stringification since the body is already an object here.

Copilot uses AI. Check for mistakes.

@sanjay-kv sanjay-kv added the under review Review under the maintainers or the admins label Oct 12, 2025
Copy link
Member

@iitzIrFan iitzIrFan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mukeshdhadhariya @sanjay-kv Updation of the Readme.md file remains and it is important as we are having new contributors, rest is fine :)
Also run 'npm run build' and if, any errors try solving or you can share it here for discussion.

Copy link
Member

@Adez017 Adez017 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reset of the things looks good.

@Adez017
Copy link
Member

Adez017 commented Oct 12, 2025

also @mukeshdhadhariya , tag the issue number assigned to this .

Copy link

Synced data from Linked Issues

Labels:

  • level 1
  • recode
  • hacktoberfest-accepted

Assignees:

  • mukeshdhadhariya

Milestones:

  • recode:launch 3.0

@mukeshdhadhariya
Copy link
Author

image

npm run build -> successfull

@sanjay-kv
Copy link
Member

@Adez017 lmk if we good to close this issue

Copy link
Member

@Adez017 Adez017 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to go from my side @sanjay-kv .
what are your thoughts @iitzIrFan

Copy link
Member

@iitzIrFan iitzIrFan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we an merge this, only remains is the documentation update, rest is fine @sanjay-kv @Adez017

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

Labels

hacktoberfest-accepted level 1 10 points recode this is label for leaderboard under review Review under the maintainers or the admins

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants