docs: приведение документации в соответствие с backend

- Auth: register без токенов до верификации (userId, message, verificationCode)
- Auth: login — 429 RATE_LIMIT_EXCEEDED при lockout, user с avatarUrl
- Auth: verify-email — { userId, code }, без Bearer
- Auth: reset-password — поле newPassword
- Profile: stats — byStack, totalTestsTaken, totalQuestions, correctAnswers, accuracy
- Tests: POST /tests возвращает полный список questions
- Tests: answer — полный snapshot отвеченного вопроса
- Tests: history — offset-пагинация (limit/offset), формат { tests, total }
- Admin: GET /admin/questions/pending, POST approve/reject, PATCH для редактирования
- DB: email_verification_codes, password_reset_tokens; обновлена question_cache_meta
- Security: CORS_ORIGINS из env, CSP/COEP отключены
- LLM: LLM_FALLBACK_MODEL, LLM_RETRY_DELAY_MS
- Onboarding: правило .env.example, JWT_SECRET >= 32 символов
This commit is contained in:
Anton
2026-03-06 13:52:24 +03:00
parent 99cd8ae727
commit 2f45a0b851
6 changed files with 318 additions and 136 deletions

View File

@@ -159,23 +159,23 @@ ${userAnswer}
- `X-Frame-Options: DENY`
- `Strict-Transport-Security: max-age=31536000; includeSubDomains`
- `X-XSS-Protection: 0` (устаревший, отключаем — CSP заменяет)
- `Content-Security-Policy` — ограничение источников скриптов, стилей, шрифтов
**CSP и COEP отключены** — бэкенд отдаёт только JSON API. Эти заголовки предназначены для HTML-страниц; для REST API они не нужны и могут мешать Swagger UI.
### CORS
Плагин: **`@fastify/cors`** с whitelist origins:
Плагин: **`@fastify/cors`**. Origins задаются через переменную окружения **`CORS_ORIGINS`** (не хардкод localhost/prod):
```ts
{
origin: [
'http://localhost:5173', // dev (Vite)
'https://samreshu.ru', // prod
],
origin: process.env.CORS_ORIGINS?.split(',') ?? ['http://localhost:5173'],
credentials: true, // для httpOnly cookies
methods: ['GET', 'POST', 'PATCH', 'DELETE'],
methods: ['GET', 'POST', 'PATCH', 'DELETE', 'PUT', 'OPTIONS'],
}
```
Методы: **GET, POST, PATCH, DELETE, PUT, OPTIONS** (OPTIONS для preflight, PUT для идемпотентных обновлений).
### HTTPS
SSL termination на nginx (reverse proxy), не в Node.js: