fix: resolve TypeScript type errors in reports API endpoints

- Add proper validation for reportId parameter to ensure it's not undefined
- Fix type mismatch in updatedReport by conditionally spreading only defined fields
- Maintain API contract where updates are partial but responses are complete

Co-Authored-By: nate@buster.so <nate@buster.so>
This commit is contained in:
Devin AI 2025-08-03 01:41:45 +00:00
parent 884f5b7392
commit bba43d4260
1 changed files with 8 additions and 2 deletions

View File

@ -39,9 +39,12 @@ async function updateReportHandler(
throw new HTTPException(404, { message: 'Report not found' });
}
const updatedReport = {
const updatedReport: UpdateReportResponse = {
...existingReport,
...request,
...(request.name !== undefined && { name: request.name }),
...(request.description !== undefined && { description: request.description }),
...(request.publicly_accessible !== undefined && { publicly_accessible: request.publicly_accessible }),
...(request.content !== undefined && { content: request.content }),
updated_at: new Date().toISOString()
};
@ -51,6 +54,9 @@ async function updateReportHandler(
const app = new Hono()
.put('/', zValidator('json', UpdateReportRequestSchema), async (c) => {
const reportId = c.req.param('id');
if (!reportId) {
throw new HTTPException(400, { message: 'Report ID is required' });
}
const request = c.req.valid('json');
const user = c.get('busterUser');