Scaffold Express TODO API with GET /todos and GET /healthz
- Add package.json with express dependency and npm start script
- Add index.js: Express server on port 3000 with /todos and /healthz endpoints
- /todos returns 3 hardcoded todo objects {id, title, done}
- /healthz returns {ok: true}
- Update README.md with Run section
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
22
index.js
Normal file
22
index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const express = require('express');
|
||||
|
||||
const app = express();
|
||||
const PORT = 3000;
|
||||
|
||||
const todos = [
|
||||
{ id: 1, title: 'Buy groceries', done: false },
|
||||
{ id: 2, title: 'Walk the dog', done: true },
|
||||
{ id: 3, title: 'Read a book', done: false },
|
||||
];
|
||||
|
||||
app.get('/healthz', (req, res) => {
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
app.get('/todos', (req, res) => {
|
||||
res.json(todos);
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server listening on http://localhost:${PORT}`);
|
||||
});
|
||||
Reference in New Issue
Block a user