This repository contains the backend code for a Task Management System built using Node.js and Express.js. The system is designed to manage tasks efficiently with robust security features, including JWT-based authentication and role-based access control. The backend also leverages MongoDB for data storage and includes a comprehensive API .
This API provides a task management system with role-based access control. Users can manage tasks, with administrators having the ability to perform CRUD operations. The API includes user authentication, task management, and role-based permissions.
admin
can perform CRUD operations on tasks.POST /api/auth/register
{
"email": "[email protected]",
"username": "John Doe",
"password": "password123"
}
{
"message": "Register successful",
"user": {
"_id": "userId",
"name": "John Doe",
"email": "[email protected]"
}
}
POST /api/auth/login
{
"email": "[email protected]",
"password": "password123"
}
{
"accessToken": "jwtToken",
"refreshToken": "refreshToken",
"user": {
"_id": "userId",
"name": "John Doe",
"email": "[email protected]",
"role": "admin"
}
}
POST /api/auth/refresh-token
{
"refreshToken": "refreshToken"
}
{
"accessToken": "newAccessToken"
}
POST /api/auth/logout
{
"refreshToken": "refreshToken"
}
{
"message": "User logged out successfully"
}
POST /api/tasks
admin
.{
"title": "Complete project report",
"description": "Finish the report and submit it by the end of the week.",
"priority": "high",
"status": "pending",
"assignedTo": "userId" // Optional, user ID to whom the task is assigned.
}
{
"title": "Complete project report",
"description": "Finish the report and submit it by the end of the week.",
"priority": "high",
"status": "pending",
"assignedTo": "userId"
}
GET /api/tasks
priority
: Filter tasks by priority (e.g., low
, medium
, high
).status
: Filter tasks by status (e.g., pending
, in progress
, completed
).assignedTo
: Filter tasks by assigned user ID.[
{
"title": "Complete project report",
"description": "Finish the report and submit it by the end of the week.",
"priority": "high",
"status": "pending",
"assignedTo": "userId"
}
]
GET /api/tasks/:id
id
: The ID of the task to retrieve.{
"title": "Complete project report",
"description": "Finish the report and submit it by the end of the week.",
"priority": "high",
"status": "pending",
"assignedTo": "userId"
}
PUT /api/tasks/:id
admin
.{
"title": "Updated task title",
"description": "Updated task description",
"priority": "medium",
"status": "in progress",
"assignedTo": "userId"
}
{
"title": "Updated task title",
"description": "Updated task description",
"priority": "medium",
"status": "in progress",
"assignedTo": "userId"
}
DELETE /api/tasks/:id
admin
.id
: The ID of the task to delete.{
"message": "Task deleted"
}
User:
Admin:
{
"name": "Admin User",
"email": "[email protected]",
"password": "adminpassword",
"role": "admin"
}