Final Todo Project with Node.js and Express — a practical guide to Node.js final todo project with clear examples you can reuse in real projects.
Final Todo Project with Node.js and Express — 55/55 in the Node.js series. Full playlist companion: Node.js complete course on YouTube. Prefer one article? Read the complete Node.js tutorial.
Short description
The final project combines everything: Express routes, Mongoose models, JWT-protected endpoints, validation, and clean project structure.
Steps
- Create Express app with dotenv, cors, and JSON parsing.
- Add User + Todo Mongoose models.
- Implement register/login with JWT.
- Protect todo CRUD routes with auth middleware.
Todo model + protected route sketch
const todoSchema = new mongoose.Schema({
title: { type: String, required: true },
done: { type: Boolean, default: false },
user: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
}, { timestamps: true });
app.get('/api/todos', auth, async (req, res) => {
const todos = await Todo.find({ user: req.user.sub }).sort('-createdAt');
res.json(todos);
});
app.post('/api/todos', auth, async (req, res) => {
const todo = await Todo.create({ title: req.body.title, user: req.user.sub });
res.status(201).json(todo);
});