refactor: replace indexer handler methods with data-driven collection configs (#25)
* refactor: replace 18 indexer handler methods with data-driven collection configs
Extract duplicated try/catch/log/throw scaffolding (~108 lines per handler)
into three generic methods: genericCreate, genericUpdate, genericDelete.
Each of the 5 collection types (post, forum, category, membership, modAction)
is now defined as a CollectionConfig object that supplies collection-specific
logic via toInsertValues/toUpdateValues callbacks. The 15 handler methods
become thin one-line delegations to the generic methods. Reaction stubs
remain as-is (no table yet).
All existing behavior is preserved: same SQL queries, same log messages,
same error handling, same transaction boundaries. Updates are now uniformly
wrapped in transactions for consistency.
* fix: address critical error handling issues in indexer refactoring
**Issue #1: Silent failure logging (Critical)**
- Added skip tracking in genericCreate/genericUpdate
- Success logs now only fire when operations actually happen
- Before: Transaction succeeds with no insert, logs "[CREATE] Success"
- After: Skipped operations don't log success (console.warn still fires in configs)
**Issue #2: Database error swallowing (Critical)**
- Removed catch block from getForumIdByDid that returned null for ALL errors
- Database connection failures now propagate to generic handler's catch block
- Before: DB errors became indistinguishable from "forum not found"
- After: Infrastructure failures bubble up, logged and re-thrown
**Issue #3: Test coverage (Critical)**
- Added 18 critical test cases for refactored generic methods
- Tests cover: transaction rollback (3), null return paths (6), error re-throwing (4), delete strategies (5)
- Verifies behavioral equivalence after consolidating 15 handlers into 3 generic methods
- All 152 tests pass (was 141)
Addresses PR #25 review feedback from code-reviewer, silent-failure-hunter, and pr-test-analyzer agents.
---------
Co-authored-by: Claude <noreply@anthropic.com>