diff options
| author | Christian Cleberg <[email protected]> | 2026-04-11 12:34:11 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-11 12:34:11 -0500 |
| commit | 1878dff520ee2e424b088a963c8f6417f5106ce9 (patch) | |
| tree | df094ec09d8b26bac56c08d1408a2fab35ac9e7d /README.md | |
| parent | acbff854f2da96bddcaede1385e7fefeba0fb34b (diff) | |
| download | hutch-stats-1878dff520ee2e424b088a963c8f6417f5106ce9.tar.gz hutch-stats-1878dff520ee2e424b088a963c8f6417f5106ce9.tar.bz2 hutch-stats-1878dff520ee2e424b088a963c8f6417f5106ce9.zip | |
feat: harden contribution api for production use
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -9,7 +9,7 @@ The current V1 is intentionally narrow and production-oriented: - polling-based ingestion - complete `todo.sr.ht` ingestion path - practical `git.sr.ht` commit ingestion for tracked repositories -- API-key protection for `/api/*` +- public read-only contribution endpoints plus API-key protection for mutating/admin routes - Alembic-managed schema migrations ## What It Does @@ -75,7 +75,7 @@ Tracked git repositories are persisted in the `tracked_repositories` table and s Environment variables: -- `API_KEY`: required header token for all `/api/*` routes via `X-API-Key` +- `API_KEY`: required header token for mutating/admin routes via `X-API-Key` - `ENABLE_SCHEDULER`: defaults to `false`; enables in-process polling when set to `true` - `SRHT_TOKEN`: bearer token for SourceHut GraphQL - `TODO_SRHT_ENDPOINT`: defaults to `https://todo.sr.ht/query` @@ -189,15 +189,13 @@ Response: ### Contribution Calendar by Year ```bash -curl "http://127.0.0.1:8000/api/contributions/~ccleberg?year=2026" \ - -H "X-API-Key: replace-me" +curl "http://127.0.0.1:8000/api/contributions/~ccleberg?year=2026" ``` ### Contribution Calendar by Date Range ```bash -curl "http://127.0.0.1:8000/api/contributions/~ccleberg?from=2026-01-01&to=2026-03-30" \ - -H "X-API-Key: replace-me" +curl "http://127.0.0.1:8000/api/contributions/~ccleberg?from=2026-01-01&to=2026-03-30" ``` Example response: @@ -218,8 +216,7 @@ Example response: ### Contribution Stats ```bash -curl "http://127.0.0.1:8000/api/contributions/~ccleberg/stats?year=2026" \ - -H "X-API-Key: replace-me" +curl "http://127.0.0.1:8000/api/contributions/~ccleberg/stats?year=2026" ``` Example response: @@ -292,7 +289,8 @@ pytest Covered areas: - health endpoint -- API key enforcement +- public read-only contribution endpoints +- API key enforcement for mutating/admin routes - calendar aggregation - zero-filled ranges - stats calculations |
