2.8 KiB
2.8 KiB
1) Prioritized debt list
- Monolithic
actions/index.js(over-coupled “god module”) - Inconsistent API error handling/response contracts across
pages/api/** - Sensitive/verbose logging in app + API paths
- Endpoint sprawl and duplicated proxy patterns (
pages/api/endpoint/*_api.js) - i18n routing complexity in large rewrite maps
- Sparse automated test coverage for high-risk flows
- Legacy/stale commented patterns in critical files
2) Impact of each item
-
1)
actions/index.jsmonolith- High blast radius for any change; weak modularity and hard ownership boundaries.
- Evidence: ~100+ exports mixing search, auth, account, file, PDF, notify, CRM concerns.
-
2) API contract inconsistency
- Clients must handle errors inconsistently; reliability and observability suffer.
- Evidence: many handlers return raw
res.status(400).json(error)while others shape custom outputs.
-
3) Verbose/sensitive logging
- Privacy/security risk plus noisy telemetry.
- Evidence: 300+
console.logoccurrences, including auth/email/upload-related contexts.
-
4) Endpoint duplication
- Maintenance cost and drift risk (validation/auth/error semantics diverge over time).
- Evidence: repeated patterns across many
_api.jsproxy handlers.
-
5) i18n rewrite complexity
- Higher risk of EN/CY divergence as routes evolve.
- Evidence: large manual rewrite map + separate i18n page namespace config.
-
6) Sparse tests
- Release confidence depends heavily on manual checks; slower, riskier change cadence.
-
7) Stale patterns
- Increased cognitive load and unclear source-of-truth behavior in some modules.
3) Recommended next cleanup targets
- Decompose
actions/index.jsby domain (structure-only first, keep barrel exports). - Add shared API handler utilities for validation/error envelope; migrate top sensitive endpoints first.
- Implement logging redaction wrapper + policy and remove direct logs in auth/email/file paths.
- Create high-risk smoke tests (auth callback, search endpoint, upload negative-path, email failure-path).
- Extract proxy/integration helpers (token/hash/header/retry) to reduce endpoint duplication.
- Add EN/CY parity CI checks for route and locale key consistency.
4) Runtime note (updated)
server.jsandserver/server.jsexist in the repository but are not the active production concern for the current refactor stream.- Current baseline runtime for this debt plan is the standard Next runtime path (
npm start). - Runtime canonicalization is therefore removed from the active prioritized debt list unless deployment evidence changes.
If you want, I can convert this into a sprint-ready debt register (ID, owner, effort, risk reduction, target milestone).