You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Product doc section 5.12 specifies a Public REST API for programmatically creating, updating, and sharing DevCards. Design and implement the versioned public API under /api/v1/ with full OpenAPI 3.1 documentation generated at runtime.
Context
The current backend at apps/backend/src/routes/ serves internal app routes. This task builds a separate, stable, versioned public API surface with API key authentication (distinct from session auth) and machine-readable docs.
Tasks
design the API key authentication strategy:
add ApiKey model to Prisma schema: id, userId, keyHash (bcrypt), label, lastUsed, createdAt, revokedAt.
add POST /api/v1/keys (session auth) to create a key — returns the raw key once, never again.
add DELETE /api/v1/keys/:id to revoke.
create a Fastify plugin apps/backend/src/plugins/apiKey.ts that validates Authorization: Bearer <key> on /api/v1/ routes.
implement v1 endpoints:
GET /api/v1/profiles/me — returns authenticated user's full profile.
PUT /api/v1/profiles/me/links — add a platform link.
DELETE /api/v1/profiles/me/links/:id — remove a link.
GET /api/v1/profiles/:username — public profile read.
register @fastify/swagger and @fastify/swagger-ui to auto-generate OpenAPI spec from route schemas.
serve the spec at GET /api/v1/openapi.json and UI at /api/v1/docs.
write integration tests for API key creation, rotation, revocation, and endpoint access.
add API key management UI stub in web settings page.
Acceptance Criteria
/api/v1/docs renders a working Swagger UI.
API keys authenticate correctly and rate-limited separately from session users.
all v1 endpoints conform to the OpenAPI spec.
revoking a key immediately returns 401 on next use.
Difficulty
senior — requires auth system design, OpenAPI tooling, Prisma schema evolution, and versioning strategy.
Summary
Product doc section 5.12 specifies a Public REST API for programmatically creating, updating, and sharing DevCards. Design and implement the versioned public API under
/api/v1/with full OpenAPI 3.1 documentation generated at runtime.Context
The current backend at
apps/backend/src/routes/serves internal app routes. This task builds a separate, stable, versioned public API surface with API key authentication (distinct from session auth) and machine-readable docs.Tasks
ApiKeymodel to Prisma schema:id,userId,keyHash(bcrypt),label,lastUsed,createdAt,revokedAt.POST /api/v1/keys(session auth) to create a key — returns the raw key once, never again.DELETE /api/v1/keys/:idto revoke.apps/backend/src/plugins/apiKey.tsthat validatesAuthorization: Bearer <key>on/api/v1/routes.GET /api/v1/profiles/me— returns authenticated user's full profile.PUT /api/v1/profiles/me/links— add a platform link.DELETE /api/v1/profiles/me/links/:id— remove a link.GET /api/v1/profiles/:username— public profile read.@fastify/swaggerand@fastify/swagger-uito auto-generate OpenAPI spec from route schemas.GET /api/v1/openapi.jsonand UI at/api/v1/docs.Acceptance Criteria
/api/v1/docsrenders a working Swagger UI.Difficulty
senior— requires auth system design, OpenAPI tooling, Prisma schema evolution, and versioning strategy.