Skip to content

Move GitHub token server-side & add ETag conditional caching to reduce API calls #891

@mukeshdhadhariya

Description

@mukeshdhadhariya

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.

Metadata

Metadata

Type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions