A simple CLI-based and HTTP-based Task Manager built with Node.js, designed to help beginners understand core Node.js concepts including modules, file system operations, JSON handling, and server creation.
This project tests your understanding of:
-
Node.js Modules (built-in and custom)
-
File System operations (read/write)
-
JSON data manipulation
-
Creating a basic HTTP server
-
Command-line interactions
-
Error handling
-
Using
package.json
task-manager/
├── package.json # Project metadata and dependencies
├── app.js # Main CLI & server logic
├── taskManager.js # Custom module for task operations
└── tasks.json # Task data storage (as JSON)
-
Clone the repository or create the project directory
-
Initialize Node.js:
npm init -y
-
Create the file structure as shown above.
-
Run the application using:
node app.js [command]
-
addTask(title, description)– Add a new task -
getAllTasks()– Get all tasks -
markTaskComplete(taskId)– Mark a task as completed -
deleteTask(taskId)– Delete a task by ID -
saveTasksToFile()– Save tasks to tasks.json -
loadTasksFromFile()– Load tasks from tasks.json
{
"id": 1,
"title": "Learn Node.js",
"description": "Complete the beginner tutorial",
"completed": false,
"createdAt": "2025-05-27T10:30:00.000Z"
}# Add a new task
node app.js add "Buy groceries" "Milk, bread, eggs"
# List all tasks
node app.js list
# Mark a task as completed
node app.js complete 1
# Delete a task
node app.js delete 2
# Start HTTP server
node app.js serverWhen you run:
node app.js serverThe server starts on http://localhost:3000 with the following endpoints:
| Method | Endpoint | Description |
|---|---|---|
| GET | / | Welcome message |
| GET | /tasks | Retrieve all tasks (JSON) |
| POST | /tasks | Add a new task (JSON body) |
✓ Task added successfully!
ID: 1, Title: "Buy groceries"=== Your Tasks ===
[1] Buy groceries (Pending)
Description: Milk, bread, eggs
Created: 2025-05-27 10:30 AM
[2] Learn Node.js (Completed ✓)
Description: Complete the beginner tutorial
Created: 2025-05-27 09:15 AMThe application handles:
-
File read/write errors
-
Missing/invalid command arguments
-
Non-existent task IDs
-
Malformed JSON data
-
Server and route errors
-
✅ Node.js module system
-
✅ JSON file storage and manipulation
-
✅ File system read/write operations
-
✅ Building a CLI-based app with process.argv
-
✅ Creating a basic HTTP server with http module
-
✅ Writing reusable and testable code with validation and error handling
This project is part of a beginner assessment for learning Node.js and understanding how to build real-world CLI and server-based applications.
This project is open for learning purposes. Feel free to use and modify for educational goals.