Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🚀 Getting Started

🛠️ Prerequisites

  • Node.js v14+
  • MongoDB URI (local or cloud)

📦 Installation

git clone https://github.com/rupak-at/taskManager_backend.git
cd server
npm install

⚙️ Environment Variables

Create a .env file:

PORT=4000
MONGO_URI=your_mongo_connection_string

▶️ Start the Server

npm run dev

🧠 API Endpoints

Base URL: http://localhost:4000/api


✅ Create Task

POST /task

Body:

{
  "title": "Finish README",
  "description": "Write a detailed API usage guide",
  "status": "in-progress"
}

📅 Get All Tasks

GET /task

Query Params:

  • status (optional): pending | completed | in-progress
  • sort (optional): createdAt or -createdAt
  • limit (optional): Number of tasks per page (default: 3)
  • page (optional): Page number (default: 1)

Example:

GET /task?status=pending&page=2&sort=-createdAt&limit=2

🔍 Get Task By ID

GET /task/:id


✏️ Update Task (title, description, or status)

PUT /task/:id

Body:

{
  "title": "Updated Task",
  "description": "Updated Description",
  "status": "completed"
}

🛠 Update Task Status Only

PATCH /task/:id/status

Body:

{
  "status": "in-progress"
}

❌ Delete Task

DELETE /task/:id


📊 Pagination & Filtering

Supports:

  • Status filtering: status=pending
  • Sorting by creation date: sort=createdAt or -createdAt
  • Pagination: limit and page query params

🧺 Example Response (GET /task)

{
  "msg": "All Tasks",
  "tasks": [
    {
      "_id": "64fe6a9232d8f2e9a4a9c12d",
      "title": "Complete UI",
      "description": "Design landing page",
      "status": "pending",
      "createdAt": "2024-04-10T12:00:00Z"
    }
  ],
  "pagination": {
    "totalTasks": 12,
    "totalPages": 4,
    "currentPage": 2,
    "perPage": 3
  }
}

📁 Folder Structure

📆 project-root
🗂️ controller/
│   └── taskController.js
🗂️ middleware/
│   └── dataValidation.js
🗂️ model/
│   └── taskModel.js
🗂️ router/
│   └── taskRoute.js
🗂️ db/
│   └── connection.js
└── index.js

About

a complete backend for task manager with crud operations with joi validation , with paginatin sorting and filtering

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages