refactor: collapse repeated blocks in documents routes and documentOps
routes/documents.ts carried the same select-doc/ensureDocAccess/404 block ten times, the extension allowlist three times, the best-effort Office->PDF rendition four times, and the version-insert/point-current pair twice; each is now one helper with identical status codes, check ordering, and response bodies. documentOps' generateDocx duplicated persistGeneratedFile end to end - it now delegates (generated DOCX still gets no PDF rendition), and read_document's dev-log narration went with it. -420 lines across the pair. Verified: tsc clean, 8 affected suites (53 tests) green, filenames and result shapes byte-compatible (renderer already used safeGeneratedFilename, persistGeneratedFile returns the legacy shape). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QUsMXzBsEJ27DjJVPSfW5o
| Repository | eliziff/Beaver |
|---|---|
| Author | Eli Ziff <eliasziff@gmail.com> |
| Authored | |
| Parents | 5a105b9d |
| Stats | 2 files changed , +382 , -802 |
| Part of | Internal cleanup, dead-code removal, and the canonical route builder |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-fb4d47c1.md
from inside the repo you want the change in.