bereke1t2/cpd-hub-backend/phase-10-api-hardening

Claude Code and agent skill by bereke1t2/cpd-hub-backend

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Install

npx vskill@latest install bereke1t2/cpd-hub-backend/phase-10-api-hardening

SKILL.md

The same SKILL.md was published earlier as bereke1t2/cpd-hub-backend/phase-10-api-hardening.

Phase 10 — API Hardening

Goal: Make the API production-grade at the edges: validate every input, paginate every list, rate-limit auth and writes, finalize CORS, and publish an OpenAPI spec so the contract is documented and testable.

Depends on: the feature phases (1–9). Risk: Low. Additive guards; don't change response shapes the client parses.


Checklist

  • [ ] 10.1 Validate all POST/PUT bodies (extend the Phase-3 bindJSON to every write).
  • [ ] 10.2 Pagination helper for list endpoints (?limit=&offset=), sane caps.
  • [ ] 10.3 Rate limiting on /auth/* and write actions (token-bucket per IP/user).
  • [ ] 10.4 CORS finalized from config; lock down origins in production.
  • [ ] 10.5 Security headers + body size limit.
  • [ ] 10.6 OpenAPI 3 spec (docs/openapi.yaml) covering every route.

10.1 Validation everywhere

Every handler that binds a body uses bindJSON (Phase 3) so malformed/invalid input returns a clean 400. Add binding tags to the remaining request structs (goal, streak, etc.). Reject unknown problem/contest ids with 404, not 500.

10.2 Pagination

Copy `pagination.go` to internal/delivery/httpdelivery/pagination.go. It parses limit/offset with defaults (20/0) and a max (100). Apply to GET /problems, /users, /activity, /submissions. Pass the bounds into the repo List queries (LIMIT $n OFFSET $m). Keep returning a bare array unless you choose the metadata envelope — if you add {items, total, limit, offset}, update the client parser in the same PR.

10.3 Rate limiting

Copy `ratelimit.go` to internal/delivery/httpdelivery/ratelimit.go: an in-memory token-bucket keyed by client IP (and by username for authenticated writes). Apply a strict bucket to /auth/login and /auth/signup (e.g. 5/min) to blunt credential stuffing, and a looser one to write actions. For multi-instance deployments, swap the in-memory store for Redis later — the interface stays the same.

10.4 CORS

The Phase-1 CORS middleware reads origins from config. In production set CORS_ORIGINS to the explicit web origin(s); never ship * with credentials. Mobile native clients don't send Origin, so they're unaffected.

10.5 Security headers + body cap

Add a small middleware setting X-Content-Type-Options: nosniff, X-Frame-Options: DENY, and a http.MaxBytesReader (e.g. 1 MB) on request bodies so a giant payload can't exhaust memory. Include it in the middleware stack from Phase 1.

10.6 OpenAPI spec

Copy `openapi.yaml` to docs/openapi.yaml and complete it: every path, request body, and response schema. Keep it in sync with routes.go — a stale spec is worse than none. Optionally serve it at GET /openapi.yaml and a Swagger UI at /docs (dev only). This is the artifact the mobile team checks field names against.


Definition of Done

  • [ ] Every write endpoint rejects invalid bodies with a 400 + clear message.
  • [ ] List endpoints honor limit/offset and cap at 100.
  • [ ] Auth endpoints are rate-limited; rapid login attempts get 429.
  • [ ] Production CORS allows only the configured origins.
  • [ ] Oversized bodies are rejected; security headers present.
  • [ ] docs/openapi.yaml describes every route and matches the running server.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/bereke1t2/cpd-hub-backend/phase-10-api-hardening/badge)](https://verified-skill.com/skills/bereke1t2/cpd-hub-backend/phase-10-api-hardening)

Something wrong with this skill or its page? Tell us.