This is a simple Todo List application built with Node.js, Express, and EJS templating.
It allows users to create, view, update, and delete todo tasks.
├── config/ ├── middleware/ ├── modules/ ├── routes/ ├── views/ ├── node_modules/ ├── .env ├── .gitignore ├── main.js ├── package.json
yaml Copy code
✔ Create new todo tasks
✔ View all tasks
✔ Update existing tasks
✔ Delete tasks
✔ MVC structured backend using Express
✔ EJS views for frontend rendering
- Node.js (JavaScript runtime)
- Express.js (Web framework)
- EJS (Templating engine)
- HTML / CSS for frontend views
- (Optional)
.envfor configuration
git clone https://github.com/DeveshTenguriya/todo.git
cd todo
2. Install Dependencies
Make sure you have Node.js installed (v14+ recommended). Then install:
bash
Copy code
npm install
3. Create Environment File
Create a .env file in the project root with content:
ini
Copy code
PORT=3000
You can choose any PORT you like.
▶️ Start the Project
Start the server:
bash
Copy code
npm start
You should see output like:
arduino
Copy code
Server running on http://localhost:3000
Now open your browser and go to:
arduino
Copy code
http://localhost:3000
📌 How to Use the App
✔ From the Browser UI
Once the server is running:
Visit http://localhost:PORT/
Add a new todo
See the list of saved todos
Edit existing todos
Delete tasks
📡 API Endpoints
This project serves both UI and backend. Below are the main API endpoints (assumed from typical Express Todo setup):
Method Route Description
GET / List all todos (UI)
POST /todos Create a new todo task
GET /todos/edit/:id Get form to edit a specific todo
POST /todos/update/:id Update todo by id
GET /todos/delete/:id Delete todo by id
Note: If your routes are named differently, update this section accordingly.
🔁 Example API Calls
Use curl / Postman to test backend routes:
👉 Add a new todo:
bash
Copy code
curl -X POST http://localhost:3000/todos \
-H "Content-Type: application/json" \
-d '{"title":"Learn Node.js"}'
👉 Get all todos:
bash
Copy code
curl http://localhost:3000/
👉 Update a todo:
bash
Copy code
curl -X POST http://localhost:3000/todos/update/123 \
-H "Content-Type: application/json" \
-d '{"title":"Updated title"}'
👉 Delete a task:
bash
Copy code
curl http://localhost:3000/todos/delete/123
(Replace 123 with real task id from your data).
🧩 Tips
You can add a database (e.g., MongoDB) later to persist todos.
If you use EJS, make sure views are loaded properly.
Use a tool like nodemon for auto-restart during development:
bash
Copy code
npm install -g nodemon
nodemon main.js
❤️ Contributing
Thanks for checking this project out! Feel free to open issues, fix bugs, or add features.