4 Commits

Author SHA1 Message Date
danny8632
cabd767abe trigger auditor (post-runner-fix) 2026-05-12 07:00:38 +00:00
danny8632
97c03033d4 trigger auditor workflow (empty commit) 2026-05-12 06:58:58 +00:00
agent dev-01
0629c6c300 Add POST /todos and DELETE /todos/:id with mutable in-memory store
- Change const todos to let for mutability
- Add express.json() middleware for body parsing
- Add nextId counter starting at 4 (after seed data)
- POST /todos: accepts {title}, returns 201 with {id, title, done:false}
- DELETE /todos/🆔 returns 204 on success, 404 if not found

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 06:55:30 +00:00
agent dev-01
d8f2645fe4 Merge issue-3 scaffold into issue-5 branch 2026-05-12 06:55:09 +00:00

View File

@@ -3,12 +3,16 @@ const express = require('express');
const app = express();
const PORT = 3000;
const todos = [
app.use(express.json());
let todos = [
{ id: 1, title: 'Buy groceries', done: false },
{ id: 2, title: 'Walk the dog', done: true },
{ id: 3, title: 'Read a book', done: false },
];
let nextId = 4;
app.get('/healthz', (req, res) => {
res.json({ ok: true });
});
@@ -17,6 +21,23 @@ app.get('/todos', (req, res) => {
res.json(todos);
});
app.post('/todos', (req, res) => {
const { title } = req.body;
const todo = { id: nextId++, title, done: false };
todos.push(todo);
res.status(201).json(todo);
});
app.delete('/todos/:id', (req, res) => {
const id = parseInt(req.params.id, 10);
const index = todos.findIndex(t => t.id === id);
if (index === -1) {
return res.status(404).end();
}
todos.splice(index, 1);
res.status(204).end();
});
app.listen(PORT, () => {
console.log(`Server listening on http://localhost:${PORT}`);
});