Description
Implement an update endpoint for announcements and improve validation on the existing delete endpoint.
1. Create PUT /api/announcements/:id
- Allow partial updates for
title, content, and priority.
- Validate input:
- At least one field must be present.
priority must be one of low, medium, high.
- Use
runValidators: true and return the updated document.
- (Optional: Enable
timestamps: true in the Announcement.js schema).
2. Harden DELETE /api/announcements/:id
- Add
ObjectId validation for the :id param.
Acceptance Criteria:
Description
Implement an update endpoint for announcements and improve validation on the existing delete endpoint.
1. Create
PUT /api/announcements/:idtitle,content, andpriority.prioritymust be one oflow,medium,high.runValidators: trueand return the updated document.timestamps: truein theAnnouncement.jsschema).2. Harden
DELETE /api/announcements/:idObjectIdvalidation for the:idparam.Acceptance Criteria:
PUT /:idupdates the correct document and returns it.PUT /:idreturns400if the body is empty or validation fails.PUT /:idreturns404for a valid ID that doesn't exist.PUTandDELETEboth return400for an invalidObjectIdformat.