feat: Add Cloudflare Workers support #4714
Open
+2,555
−204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cloudflare Workers Support
Description
This PR enables
github-readme-statsto be deployed on Cloudflare Workers.This is a strategic addition to address the "Deployment Paused" issues caused by Vercel's free tier limits. Cloudflare Workers provides 100,000 requests/day on its free tier, offering a robust alternative for the community.
Changes
src/common/adapter.js): Translates standard Request/Response objects to the Express-stylereq/resexpected by existing handlers.src/worker.js): Handles routing and dispatches requests to the card generators using the adapter.wrangler.toml): Configuration for Cloudflare deployment, using thenodejs_compatcompatibility flag.gist.jsandwakatime.jsto use standard ES imports for JSON, replacingcreateRequireto support modern bundling.Verification
wrangler dev(port 8787)./apiworks and invokes the stats fetcher (returning error SVG when tokens are missing, which proves execution path).How to Test
npm installnpm install -D wrangler(if not present)npx wrangler devhttp://localhost:8787/api?username=anuraghazraCloses # (if applicable)