[Backend] API Response Polish — rate limit headers + job timestamps #58
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & Why
Two small improvements to make the API spec-complete:
/api/demoenforces 5 req/hr/IP but returns noX-RateLimit-*headers — clients cannot track quota proactivelyGET /api/jobs/:iddoes not exposecreatedAtorcompletedAteven though the DB stores them — needed for latency measurementDone looks like
GET /api/demoresponse (200 and 429) includes:X-RateLimit-Limit: 5X-RateLimit-Remaining: N(0–5)X-RateLimit-Reset: <unix-epoch-seconds>GET /api/jobs/:idresponse JSON includescreatedAt(ISO 8601) andcompletedAt(ISO 8601, null if not done)POST /api/jobsresponse includescreatedAtOut of scope
/api/demoTasks
/api/demo— ExtendcheckRateLimitreturn value to include current count; exposeX-RateLimit-Limit,X-RateLimit-Remaining,X-RateLimit-Resetheaders on all responses from the demo route handler (200 and 429).GET /api/jobs/:idto includecreatedAtandcompletedAt(=updatedAtwhenstate === "complete", else null). Same forPOST /api/jobscreation response.Relevant files
artifacts/api-server/src/routes/demo.tsartifacts/api-server/src/routes/jobs.tsartifacts/api-server/src/lib/rate-limiter.tsPR created. Investigation revealed that the requirements for rate limit headers on
/api/demoand job timestamps on/api/jobs/:idandPOST /api/jobsare already met by the existing codebase. No code changes were necessary. PR #96