Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Todo List API

A simple Todo List REST API using Node.js and Express with full CRUD operations. Data is stored in memory, no database required.

## API Documentation

Postman documentation is available here:
https://documenter.getpostman.com/view/51751420/2sBXcEk1FV

## Tech Stack

- **Runtime:** Node.js
- **Framework:** Express
- **Other:** uuid, dotenv

## Endpoints

- GET /api/todos - List all todos
- GET /api/todos/:id - Get a single todo
- POST /api/todos - Create a new todo
- PUT /api/todos/:id - Update a todo
- DELETE /api/todos/:id - Delete a todo

## Details

- Data is stored in memory using an array and will reset when the server restarts.
- MVC-inspired folder structure
- Each todo is assigned a unique UUID on creation.
- Input validation and error handling

### Request Body
- POST /api/todos requires `title` (string)
- PUT /api/todos/:id requires `title` (string) and `completed` (boolean)

### Response Structure
- All todos contain `id`, `title`, `completed`, and `createdAt` fields
- Create and update responses include a message and the todo object
- Delete response returns a success message only

### Error Responses & Status Codes
- `200` - Success
- `201` - Todo created successfully
- `400` - Missing or invalid request body
- `404` - Todo not found
- `409` - Todo already exists

### Validation Rules
- `title` is required and cannot be empty
- `completed` is required on update and must be a boolean
- Duplicate todo titles are not allowed

## Project Structure

```
backend/
├── src/
│ ├── controllers/
│ │ └── todoController.js # CRUD logic
│ ├── data/
│ │ └── store.js # In-memory storage
│ ├── routes/
│ │ └── todoRoutes.js # Routes
│ └── server.js # Express app setup
├── .env.example
├── index.js # Entry point
└── package.json
```

## Author
- **GitHub:** [github.com/deyperfect](https://github.com/deyperfect)
1 change: 1 addition & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PORT=4000
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
96 changes: 0 additions & 96 deletions backend/README-1-2-YEARS.md

This file was deleted.

101 changes: 0 additions & 101 deletions backend/README-3-5-YEARS.md

This file was deleted.

101 changes: 0 additions & 101 deletions backend/README-5-YEARS-Plus.md

This file was deleted.

11 changes: 3 additions & 8 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
const express = require("express");
const app = express();
const PORT = process.env.PORT || 4000;

// Basic route
app.get("/", (req, res) => {
res.send("Hello from Express!");
});
require('dotenv').config();
const app = require('./src/server');
const PORT = process.env.PORT;

// Start server
app.listen(PORT, () => {
Expand Down
Loading