(req, res, params)
| 360 | * POST /sessions/:id/annotations - Add annotation to session. |
| 361 | */ |
| 362 | const addAnnotationHandler: RouteHandler = async (req, res, params) => { |
| 363 | try { |
| 364 | const body = await parseBody<Omit<Annotation, "id" | "sessionId" | "status" | "createdAt">>(req); |
| 365 | |
| 366 | if (!body.comment || !body.element || !body.elementPath) { |
| 367 | return sendError(res, 400, "comment, element, and elementPath are required"); |
| 368 | } |
| 369 | |
| 370 | const annotation = addAnnotation(params.id, body); |
| 371 | |
| 372 | if (!annotation) { |
| 373 | return sendError(res, 404, "Session not found"); |
| 374 | } |
| 375 | |
| 376 | sendJson(res, 201, annotation); |
| 377 | } catch (err) { |
| 378 | sendError(res, 400, (err as Error).message); |
| 379 | } |
| 380 | }; |
| 381 | |
| 382 | /** |
| 383 | * PATCH /annotations/:id - Update an annotation. |
nothing calls this directly
no test coverage detected
searching dependent graphs…