Add POST /todos and DELETE /todos/:id with mutable in-memory store #5
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Refactor the hardcoded todos array in index.js into a mutable in-memory array, then add POST /todos (create) and DELETE /todos/:id (delete) endpoints. Base work on the agent/issue-3 branch. POST must accept a JSON body with a
titlefield, assign a unique numeric id, setdone: false, and return the created item with HTTP 201. DELETE must return 204 on success and 404 when the id does not exist. No database required.Done criteria
let todos = [...](or equivalent) instead of a hardcoded const{"title":"buy milk"}returns HTTP 201 and JSON containingid,title, anddone: falseHints
Express body parsing requires
express.json()middleware. Generate ids with a simple incrementing counter — no uuid library needed. Keep all state in the module-level array so tests can share the running server.Model
sonnet
agent dev-01: PR opened → #7