diff --git a/api/index.js b/api/index.js index 21448f9..67619f4 100644 --- a/api/index.js +++ b/api/index.js @@ -55,11 +55,14 @@ export default async (req, res) => { parseArray(exclude_repo), ); - const cacheSeconds = clampValue( + let cacheSeconds = clampValue( parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10), CONSTANTS.FOUR_HOURS, CONSTANTS.ONE_DAY, ); + cacheSeconds = process.env.CACHE_SECONDS + ? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds + : cacheSeconds; res.setHeader( "Cache-Control", diff --git a/api/pin.js b/api/pin.js index 4838b0f..3383b00 100644 --- a/api/pin.js +++ b/api/pin.js @@ -44,6 +44,9 @@ export default async (req, res) => { CONSTANTS.FOUR_HOURS, CONSTANTS.ONE_DAY, ); + cacheSeconds = process.env.CACHE_SECONDS + ? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds + : cacheSeconds; /* if star count & fork count is over 1k then we are kFormating the text diff --git a/api/top-langs.js b/api/top-langs.js index f01648e..fdb6702 100644 --- a/api/top-langs.js +++ b/api/top-langs.js @@ -62,11 +62,14 @@ export default async (req, res) => { count_weight, ); - const cacheSeconds = clampValue( + let cacheSeconds = clampValue( parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10), CONSTANTS.FOUR_HOURS, CONSTANTS.ONE_DAY, ); + cacheSeconds = process.env.CACHE_SECONDS + ? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds + : cacheSeconds; res.setHeader( "Cache-Control", diff --git a/api/wakatime.js b/api/wakatime.js index 7ae93b5..ec0c813 100644 --- a/api/wakatime.js +++ b/api/wakatime.js @@ -46,6 +46,9 @@ export default async (req, res) => { CONSTANTS.FOUR_HOURS, CONSTANTS.ONE_DAY, ); + cacheSeconds = process.env.CACHE_SECONDS + ? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds + : cacheSeconds; if (!cache_seconds) { cacheSeconds = CONSTANTS.FOUR_HOURS; diff --git a/readme.md b/readme.md index 2184318..d9d8489 100644 --- a/readme.md +++ b/readme.md @@ -81,24 +81,44 @@ Please visit [this link](https://give.do/fundraisers/stand-beside-the-victims-of

-# Features -- [GitHub Stats Card](#github-stats-card) -- [GitHub Extra Pins](#github-extra-pins) -- [Top Languages Card](#top-languages-card) -- [Wakatime Week Stats](#wakatime-week-stats) -- [Themes](#themes) - - [Responsive Card Theme](#responsive-card-theme) -- [Customization](#customization) - - [Common Options](#common-options) - - [Stats Card Exclusive Options](#stats-card-exclusive-options) - - [Repo Card Exclusive Options](#repo-card-exclusive-options) - - [Language Card Exclusive Options](#language-card-exclusive-options) - - [Wakatime Card Exclusive Option](#wakatime-card-exclusive-options) -- [Deploy Yourself](#deploy-on-your-own) - - [On Vercel](#on-vercel) - - [On other platforms](#on-other-platforms) - - [Keep your fork up to date](#keep-your-fork-up-to-date) +# Features + +- [GitHub Stats Card](#github-stats-card) + - [Hiding individual stats](#hiding-individual-stats) + - [Showing icons](#showing-icons) + - [Themes](#themes) + - [Customization](#customization) +- [GitHub Extra Pins](#github-extra-pins) + - [Usage](#usage) + - [Demo](#demo) +- [Top Languages Card](#top-languages-card) + - [Usage](#usage-1) + - [Language stats algorithm](#language-stats-algorithm) + - [Exclude individual repositories](#exclude-individual-repositories) + - [Hide individual languages](#hide-individual-languages) + - [Show more languages](#show-more-languages) + - [Compact Language Card Layout](#compact-language-card-layout) + - [Donut Chart Language Card Layout](#donut-chart-language-card-layout) + - [Donut Vertical Chart Language Card Layout](#donut-vertical-chart-language-card-layout) + - [Pie Chart Language Card Layout](#pie-chart-language-card-layout) + - [Hide Progress Bars](#hide-progress-bars) + - [Demo](#demo-1) +- [Wakatime Week Stats](#wakatime-week-stats) + - [Demo](#demo-2) + - [All Demos](#all-demos) + - [Quick Tip (Align The Repo Cards)](#quick-tip-align-the-repo-cards) + - [Deploy on your own](#deploy-on-your-own) + - [On Vercel](#on-vercel) + - [On other platforms](#on-other-platforms) + - [Disable rate limit protections](#disable-rate-limit-protections) + - [Keep your fork up to date](#keep-your-fork-up-to-date) + - [:sparkling\_heart: Support the project](#sparkling_heart-support-the-project) + +# Important Notice + +> **Warning** +> Since the GitHub API only [allows 5k requests per hour per user account](https://docs.github.com/en/graphql/overview/resource-limitations), the public Vercel instance hosted on `https://github-readme-stats.vercel.app/api` could possibly hit the rate limiter (see #1471). We use caching to prevent this from happening (see https://github.com/anuraghazra/github-readme-stats#common-options). You can turn off these rate limit protections by deploying [your own Vercel instance](#disable-rate-limit-protections). # GitHub Stats Card @@ -623,6 +643,14 @@ Since the GitHub API only allows 5k requests per hour, my `https://github-readme 5. You're done 🎉 +### Disable rate limit protections + +Github Readme Stats contains several Vercel environment variables that can be used to remove the rate limit protections: + +- `CACHE_SECONDS`: This environment variable takes precedence over our cache minimum and maximum values and can circumvent these values for self Hosted Vercel instances. + +See [the Vercel documentation](https://vercel.com/docs/concepts/projects/environment-variables) on adding these environment variables to your Vercel instance. + ### Keep your fork up to date You can keep your fork, and thus your private Vercel instance up to date with the upstream using GitHub's [Sync Fork button](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork). You can also use the [pull](https://github.com/wei/pull) package created by [@wei](https://github.com/wei) to automate this process.