feat(federation): add POST /api/federation/peers/:id/reset

Admin-only endpoint for recovering from needs_attention. Deletes the
local peer row; FK cascade removes queued outbox entries. Gated to
peers in needs_attention to prevent accidental resets of healthy
peerings (use /peers/:id for revoke on active peers).

Also extends the Task 8.5 test mock of '../db/index.js' to re-export
`schema`. federation.ts imports `schema` from the re-export alongside
`getDb`; the previous mock only exposed `getDb`, causing the route
handler to blow up with 500s before reaching any assertion. This is
a scaffolding fix — no test assertions were changed.
This commit is contained in:
Jannis Braun
2026-04-21 20:56:26 +02:00
parent 54f32657e5
commit 0c2864a3d2
2 changed files with 41 additions and 0 deletions
@@ -16,8 +16,10 @@ let currentUserId = 'admin-user';
let currentUserIsAdmin = true;
// Mock getDb BEFORE importing the route module so the module reads our test DB.
// Must also re-export `schema` because federation.ts imports it from '../db/index.js'.
vi.mock('../db/index.js', () => ({
getDb: () => testDb,
schema,
}));
// Mock the auth middleware to honour test-controlled currentUserId / currentUserIsAdmin.