feat(server): codify the { success, error, code } response envelope in ok()/fail() helpers (#3962)#3990
Conversation
…mplar routes (#3962 task 1.5) Introduces src/server/utils/apiResponse.ts with ok<T>(res, data?) and fail(res, status, code, message, extra?) matching the ApiService wire contract. Converts ignoredNodeRoutes (errors → fail(); bare-array success left unchanged) and dataExchangeRoutes (import success → ok(res); three bare errors → fail() with STATS_FAILED/EXPORT_FAILED/IMPORT_FAILED codes). Deletes the now-unused local ApiErrorResponse interface. Test expectations updated to assert the full {success, error, code} envelope. CLAUDE.md documents the helper and the "does-not-unwrap-data" gotcha. REMEDIATION_EPIC.md marks 1.3 and 1.4 done with phase-log entries. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AphLfgUJWaFNAgU5UXdJ4n
|
Claude finished @Yeraze's task —— View job PR Review: feat(server): codify response envelope helpersTasks:
SummaryThis is a clean, deliberately-scoped PR. The implementation is correct, the JSDoc warning about
|
Summary
Task 1.5 of the remediation plan (#3962, Phase 1). Deliberately tiny.
src/server/utils/apiResponse.ts—ok<T>(res, data?)→{ success: true, data? }andfail(res, status, code, message, extra?)→{ success: false, error, code, ...extra }, matching whatApiServicealready parses. The JSDoc pins the load-bearing constraint discovered during investigation: the frontend returns raw JSON and does not unwrapdata, sofail()is always safe to introduce butok()may only replace handlers already emitting{ success: true }— never bare payloads.ignoredNodeRoutes.ts(fourfail()s with codes + details; deletes a local one-off error interface) anddataExchangeRoutes.ts(ok(res)+ threefail()s). Bare-payload success responses deliberately untouched.{error}handlers convert as they're touched in Phases 2/4. Not a mass conversion (per plan).Verification
success: true); typecheck clean; test-typecheck at baseline (283);npm run lint:cigreen under the new blocking ratchet.Refs #3962
🤖 Generated with Claude Code
https://claude.ai/code/session_01AphLfgUJWaFNAgU5UXdJ4n