A REST API for managing todo items, built as part of the backend development course on the MK Code Club YouTube channel.
This project provides a simple, clean backend for creating, reading, updating, and deleting todo items with a MongoDB-powered data layer.
- Create and store todo items
- Fetch all todos or a single item by ID
- Update todo status and content
- Delete records from the database
- Built-in health check endpoint
- Automatic timestamps for creation and updates
- Node.js and Express
- MongoDB with Mongoose
- dotenv for environment configuration
-
Install dependencies:
npm install
-
Create a
.envfile in the project root:PORT=3000 MONGO_URI=mongodb://localhost:27017/todoDB
Replace the MongoDB URI with your local or hosted database connection string.
-
Start the development server:
npm run dev
The API runs at http://localhost:3000 (or the port set in .env). Send JSON request bodies with the Content-Type: application/json header.
Base path: /api/todos
| Method | Endpoint | Description | Body |
|---|---|---|---|
POST |
/api/todos |
Create a todo | { "title": "Learn Express" } |
GET |
/api/todos |
Get all todos | — |
PUT |
/api/todos/:id |
Update a todo | { "title": "Learn Express", "isDone": true } |
DELETE |
/api/todos/:id |
Delete a todo | — |
GET |
/api/health-check |
Check server status | — |
Each todo has a required title, an isDone flag (defaults to false), and automatically managed createdAt and updatedAt timestamps.
Follow along with the backend development lessons on MK Code Club.