{"id":20920114,"url":"https://github.com/gifflet/github-stats-cloudflare-worker","last_synced_at":"2026-04-13T01:04:04.261Z","repository":{"id":262935124,"uuid":"888824014","full_name":"gifflet/github-stats-cloudflare-worker","owner":"gifflet","description":"A Cloudflare Worker-based API for retrieving GitHub user statistics","archived":false,"fork":false,"pushed_at":"2024-11-18T11:07:13.000Z","size":206,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T00:21:12.430Z","etag":null,"topics":["api","cloudflare","cloudflare-d1","cloudflare-kv","github","hono","typescript"],"latest_commit_sha":null,"homepage":"https://github-stats-api.sousaguilherme89.workers.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gifflet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-15T04:27:05.000Z","updated_at":"2024-11-18T11:07:17.000Z","dependencies_parsed_at":"2024-11-18T09:33:35.347Z","dependency_job_id":null,"html_url":"https://github.com/gifflet/github-stats-cloudflare-worker","commit_stats":null,"previous_names":["gifflet/api-cloudflare-worker","gifflet/github-stats-cloudflare-worker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gifflet/github-stats-cloudflare-worker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gifflet%2Fgithub-stats-cloudflare-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gifflet%2Fgithub-stats-cloudflare-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gifflet%2Fgithub-stats-cloudflare-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gifflet%2Fgithub-stats-cloudflare-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gifflet","download_url":"https://codeload.github.com/gifflet/github-stats-cloudflare-worker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gifflet%2Fgithub-stats-cloudflare-worker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265248543,"owners_count":23734255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","cloudflare","cloudflare-d1","cloudflare-kv","github","hono","typescript"],"created_at":"2024-11-18T18:08:48.587Z","updated_at":"2026-04-13T01:04:04.224Z","avatar_url":"https://github.com/gifflet.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n**Github Stats Cloudflare Worker**\n=====================\n\n**Table of Contents**\n-----------------\n\n1. [Overview 🚀](#overview-)\n2. [Features 🎉](#features-)\n3. [Getting Started 📊](#getting-started-)\n4. [Usage 💻](#usage-)\n5. [Configuration 🔧](#configuration-)\n6. [Wrangler Setup 📚](#wrangler-setup-)\n\n**Overview 🚀**\n------------\n\nThis project provides a simple API for retrieving GitHub user statistics, built using Cloudflare Workers and Hono. The API caches responses to reduce the number of requests made to the GitHub API.\n\n**Features 🎉**\n------------\n\n* Retrieves GitHub user statistics, including repository information\n* Caches responses to reduce the number of requests made to the GitHub API\n* Built using Cloudflare Workers and Hono for high performance and scalability\n\n**Getting Started 📊**\n-------------------\n\n### Prerequisites\n\n* Node.js (version 14 or higher)\n* npm (version 6 or higher)\n* Cloudflare Workers CLI (version 1.0.0 or higher)\n\n### Installation\n\n1. Clone the repository: `git clone https://github.com/gifflet/github-stats-cloudflare-worker`\n2. Install dependencies: `npm install`\n3. Configure the project: `cp wrangler.toml wrangler.toml.example` and update the `wrangler.toml` file with your Cloudflare API credentials\n\n**Usage 💻**\n---------\n\n### API Endpoints\n\n#### Get User Repositories\n* `GET /:username/repositories`: Retrieves paginated GitHub repositories for the specified username\n* Query Parameters:\n  * `page`: Page number (default: 1)\n  * `per_page`: Items per page (default: 30)\n* Example: `curl https://your-worker-url.com/gifflet/repositories?page=1\u0026per_page=30`\n\n#### Get User Metrics\n* `GET /:username/metrics`: Retrieves cached GitHub metrics for the specified username\n* Example: `curl https://your-worker-url.com/gifflet/metrics`\n\n#### Get User Badge\n* `GET /:username/badge`: Generates a dynamic SVG badge with user statistics\n* Example: \n  * Usage in markdown: `![GitHub Stats](https://your-worker-url.com/gifflet/badge)`\n  * Direct access: `curl https://your-worker-url.com/gifflet/badge`\n\n### Response Examples\n\n#### Repositories Endpoint\n```json\n{\n  \"username\": \"gifflet\",\n  \"repositories\": [...],\n  \"pagination\": {\n    \"current_page\": 1,\n    \"per_page\": 30,\n    \"has_next_page\": true,\n    \"has_previous_page\": false\n  }\n}\n```\n\n#### Metrics Endpoint\n```json\n{\n  \"username\": \"gifflet\",\n  \"total_stars\": 38,\n  \"total_forks\": 12,\n  \"total_repos\": 23,\n  \"most_used_language\": \"TypeScript\",\n  \"updated_at\": \"2024-01-15T10:00:00.000Z\"\n}\n```\n\n**Configuration 🔧**\n----------------\n\n### Environment Variables\n\n* `CACHE`: The name of the KV namespace used for caching responses\n\n### Wrangler Configuration\n\n* `wrangler.toml`: Configure the project with your Cloudflare API credentials and KV namespace settings\n\n**Wrangler Setup 📚**\n----------------------\n\n### Create a new KV namespace\n\n* `npx wrangler kv:namespace create \u003cNAMESPACE_NAME\u003e`: Creates a new KV namespace for caching responses.\n* Example: `npx wrangler kv:namespace create github-stats-api-cache`\n\n### Configure the KV namespace\n\n* `npx wrangler kv:namespace configure \u003cNAMESPACE_NAME\u003e --binding \u003cBINDING_NAME\u003e`: Configures the KV namespace with a binding name.\n* Example: `npx wrangler kv:namespace configure github-stats-api-cache --binding CACHE`\n\n### Create a D1 Database\n\n* `npx wrangler d1 create \u003cDATABASE_NAME\u003e`: Creates a new D1 database.\n* Example: `npx wrangler d1 create github-metrics`\n\n### Create and Apply Migrations\n\n1. Create a migration file:\n* `npx wrangler d1 migrations create \u003cDATABASE_NAME\u003e \u003cMESSAGE\u003e`\n* Example: `npx wrangler d1 migrations create github_metrics create-tables`\n\n2. Apply migrations to the remote database:\n* `npx wrangler d1 migrations apply \u003cDATABASE_NAME\u003e`: Applies all pending migrations to your database.\n* Example: `npx wrangler d1 migrations apply github_metrics --remote`\n\n    \u003e If you want to execute migrations locally (for development), you can use the following command:\n    * `npx wrangler d1 migrations apply \u003cDATABASE_NAME\u003e --local`: Applies migrations to local D1 database.\n    * Example: `npx wrangler d1 migrations apply github_metrics --local`\n\n### Query D1 Database\n\n* `npx wrangler d1 execute \u003cDATABASE_NAME\u003e --command \"\u003cSQL_QUERY\u003e\"`: Executes SQL commands on your D1 database.\n* Example: `npx wrangler d1 execute github_metrics --command \"SELECT * FROM github_metrics\"`\n\nYou can also execute queries locally by adding the `--local` flag:\n* Example: `npx wrangler d1 execute github_metrics --local --command \"SELECT * FROM github_metrics\"`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgifflet%2Fgithub-stats-cloudflare-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgifflet%2Fgithub-stats-cloudflare-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgifflet%2Fgithub-stats-cloudflare-worker/lists"}