Commit Graph

6 Commits

Author SHA1 Message Date
arnaudne 2d0c44e21d chore(api-docs): use default swagger-ui theme
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-15 23:34:38 +02:00
arnaudne f1998d32c1 fix(api-docs): full dark theme for Swagger UI — override all light sections 2026-06-15 19:31:54 +02:00
arnaudne e5acf75cac fix(api-docs): use relative spec URL — req.url returns internal Docker address
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-15 18:29:54 +02:00
arnaudne 5d7ef5fa3b fix(api-docs): rename openapi.json route dir to spec (dot breaks Next.js routing)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-15 18:14:01 +02:00
arnaudne 61f80e5fe4 fix(api-docs): load swagger-ui-standalone-preset.js for StandaloneLayout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-15 17:41:11 +02:00
arnaudne f59a6c5d8a feat: REST API v1 + API key management + Swagger docs
**API system**
- ApiKey model: SHA-256-hashed tokens (gw_<hex>), per-family, scoped
- Migration: 20260615210000_api_keys
- src/lib/api-auth.ts: verifyApiKey(), hasScope(), generateApiKey(), prepareKey()

**V1 endpoints** (all require Bearer gw_ token):
- GET  /api/v1/babies              — list family babies (any read scope)
- GET  /api/v1/events              — query events (events:read), babyId/type/from/to/limit/offset
- POST /api/v1/events              — log event (events:write), full metadata support
- GET  /api/v1/growth              — growth logs (growth:read)
- POST /api/v1/growth              — add measurement (growth:write), weight in grams
- GET  /api/v1/summary             — today's counts + sleep + last feed (summary:read)
- GET  /api/v1/milk                — stock lots + totalMl (milk:read)

**API key management**
- GET  /api/api-keys               — list keys (session auth)
- POST /api/api-keys               — create key, returns raw token once (session auth)
- DELETE /api/api-keys/[id]        — revoke key (session auth)

**Documentation**
- GET /api/v1/openapi.json         — OpenAPI 3.0 spec (CORS open)
- GET /api-docs                    — Swagger UI (CDN, dark themed)

**Settings UI** — "Clés API" section: create key with scope checkboxes, copy token banner (shown once), revoke, link to /api-docs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-15 17:33:25 +02:00