TASK22224: modernize generatepdf handlers
This commit is contained in:
@@ -476,3 +476,43 @@ Validation:
|
||||
Follow-ups:
|
||||
|
||||
- Remaining major modernization candidate is `pages/api/file/generateappealpdf.js` (+ optional `pages/api/file/generatepdf.js`) if we continue final closure slices.
|
||||
|
||||
---
|
||||
|
||||
### CL-012: TASK22224 generatepdf/generateappealpdf async hardening slice
|
||||
|
||||
date: 2026-03-23
|
||||
author: Cline
|
||||
scope: `pages/api/file/{generateappealpdf,generatepdf}.js`, `tests/phase21/file-handler-contract.test.cjs`
|
||||
type: change
|
||||
rationale: Execute next requested slice to modernize remaining file PDF-generation handlers still using promise chains, while preserving existing hash/response behavior.
|
||||
impact: Improves maintainability and error-path consistency for PDF generation routes; phase21 coverage now includes explicit failure contracts for both handlers.
|
||||
status: completed
|
||||
|
||||
Summary:
|
||||
|
||||
- `pages/api/file/generateappealpdf.js`
|
||||
- converted mixed promise-chain flow to `async/await` + `try/catch`
|
||||
- preserved existing guard contracts: `MISSING_REQUIRED_QUERY`, `INVALID_HASH`
|
||||
- preserved generation failure contract: `GENERATE_APPEAL_PDF_FAILED`
|
||||
- replaced JSX render call with `React.createElement(...)` compatibility form used by test loader
|
||||
- `pages/api/file/generatepdf.js`
|
||||
- converted create/upload promise-chain to `async/await` + `try/catch`
|
||||
- preserved existing guard contracts: `HASH_REQUIRED`, `INVALID_HASH`
|
||||
- preserved generation failure contract: `GENERATE_PDF_FAILED`
|
||||
- replaced JSX render call with `React.createElement(...)` compatibility form used by test loader
|
||||
- phase21 file tests expanded:
|
||||
- `generatepdf` catch-path contract (`GENERATE_PDF_FAILED`)
|
||||
- `generateappealpdf` catch-path contract (`GENERATE_APPEAL_PDF_FAILED`)
|
||||
|
||||
Validation:
|
||||
|
||||
- `node tests/phase21/api-contract-slice1.test.cjs` -> pass
|
||||
- helper: 4/4
|
||||
- file-handler: 51/51
|
||||
- email-handler: 12/12
|
||||
- endpoint-handler: 152/152
|
||||
|
||||
Follow-ups:
|
||||
|
||||
- Remaining optional cleanup in these handlers is dead import/unused local pruning (non-behavioral) if we want a final low-risk tidy pass.
|
||||
|
||||
Reference in New Issue
Block a user