TASK22229: pilot shared relay forwarding utility
This commit is contained in:
@@ -725,3 +725,42 @@ Validation:
|
||||
Follow-ups:
|
||||
|
||||
- Optional future auth hygiene (separate guarded slice): replace verbose auth `console.log` diagnostics with structured logger usage once production logging requirements are confirmed.
|
||||
|
||||
---
|
||||
|
||||
### CL-019: TASK22229 P2-S1 relay forwarding pilot (proxy endpoint cluster)
|
||||
|
||||
date: 2026-03-24
|
||||
author: Cline
|
||||
scope: `pages/api/middleware/relayForwarding.js`, `pages/api/endpoint/{getwatchedcasesproxy_api,getmyrepresentationsproxy_api,getrepresentationsproxy_api,getawaitingsubmissionproxy_api}.js`, `tests/phase21/endpoint-handler-contract.test.cjs`
|
||||
type: change
|
||||
rationale: Start Priority-2 by piloting a shared relay forwarding helper on a bounded proxy endpoint cluster to reduce duplicated token/hash/header/axios boilerplate while preserving endpoint contracts.
|
||||
impact: Maintainability and consistency improvement with no intended behavioral contract changes; error code/status/message and success payload contracts remain unchanged for migrated endpoints.
|
||||
status: completed
|
||||
|
||||
Summary:
|
||||
|
||||
- Added shared relay helper:
|
||||
- `pages/api/middleware/relayForwarding.js`
|
||||
- exports `relayGet({ queryUrl, res, errorResponse, transformData })`
|
||||
- centralizes token fetch, relay URL + hash composition, `azureHeaders`, GET execution, success/error response handling, and logging
|
||||
- Migrated pilot endpoint cluster to `relayGet`:
|
||||
- `getwatchedcasesproxy_api.js` (with existing payload transform preserved)
|
||||
- `getmyrepresentationsproxy_api.js`
|
||||
- `getrepresentationsproxy_api.js`
|
||||
- `getawaitingsubmissionproxy_api.js` (with existing payload transform preserved)
|
||||
- Updated endpoint contract tests to mock `relayGet` for migrated routes while preserving existing assertions.
|
||||
|
||||
Validation:
|
||||
|
||||
- `node tests/phase21/api-contract-slice1.test.cjs` -> pass
|
||||
- helper: 4/4
|
||||
- file-handler: 53/53
|
||||
- email-handler: 12/12
|
||||
- endpoint-handler: 152/152
|
||||
- documents-handler: 3/3
|
||||
|
||||
Follow-ups:
|
||||
|
||||
- P2-S2 rollout: migrate the next relay-heavy endpoint batch onto `relayGet`/shared forwarding utility pattern.
|
||||
- P2-S3 hardening: add shared timeout/retry config and redacted structured relay error logging policy.
|
||||
|
||||
Reference in New Issue
Block a user