feat(KB-180): add planning route diagnostics and harden JSON error handling

- Add API diagnostics to planning routes for better debugging
- Harden API JSON error handling with improved validation
- Add comprehensive tests for planning route JSON responses
- Update server routes and API layer for robustness
This commit is contained in:
gsxdsm
2026-03-31 01:38:43 -07:00
parent 9e03c47b91
commit aef82c2df9
5 changed files with 144 additions and 53 deletions

View File

@@ -166,6 +166,19 @@ export function createServer(store: TaskStore, options?: ServerOptions): ReturnT
// Rate limiting — mutation endpoints (POST/PUT/PATCH/DELETE)
app.use("/api", rateLimit(RATE_LIMITS.api));
// Planning route diagnostics for production/runtime debugging. Disabled by default.
if (process.env.KB_DEBUG_PLANNING_ROUTES === "1") {
app.use("/api/planning", (req, _res, next) => {
console.debug("[planning:request]", {
method: req.method,
path: req.path,
originalUrl: req.originalUrl,
contentType: req.headers["content-type"],
});
next();
});
}
// REST API
app.use("/api", createApiRoutes(store, options));