mirror of https://github.com/buster-so/buster.git
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:
parent
884f5b7392
commit
bba43d4260
|
@ -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');
|
||||
|
||||
|
|
Loading…
Reference in New Issue