This is a simple Task Management application built with Node.js, Express, and MongoDB.
- Create tasks with title and description
- View a list of all tasks
- Mark tasks as completed
- Edit task details
- Delete tasks
- Node.js (v14 or later)
- MongoDB
-
Clone the repository:
git clone https://github.com/dhiree/Task_Management--Nodejs cd task-management -
Install dependencies:
npm install -
Create a
.envfile in the root directory and add the following:MONGODB_URI='' PORT=4000Adjust the MONGODB_URI if your MongoDB is hosted elsewhere.
-
Start the application:
npm startFor development with auto-restart on file changes, use:
npm run dev
- POST /task - Create a new task
- GET /task - Get all tasks
- GET /task/:id - Get a specific task
- PATCH /task/:id - Update a task
- DELETE /task/:id - Delete a task
app.js: Main application filemodels/task.js: Mongoose model for tasksroutes/tasks.js: Defines the API routes and connects them to the appropriate controller functions.controller/taskController.js: Contains the logic for handling task-related requests (create, get, update, delete, etc.).
- Used MongoDB for its flexibility with document-based storage.
- Implemented RESTful API design for clear and standard endpoints.
- Used environment variables for configuration to enhance security and flexibility.
- Implemented basic validation to ensure task titles are not empty.
- Used async/await for cleaner handling of asynchronous operations.
- The application provides meaningful error messages for invalid operations.
- HTTP status codes are used appropriately to indicate the nature of responses.