A RESTful API for managing tasks built with Node.js, Express, and MongoDB, with a clean frontend interface.
- Create, read, update, and delete tasks
- Task status tracking
- Pagination and filtering support
- Frontend interface for task management
- Responsive design with modern CSS
- Error handling and custom response formats
- Query parameter parsing for advanced filtering
- Node.js (v14 or higher)
- MongoDB
- Modern web browser
- Clone the repository
- Install dependencies:
npm install
- Create a
.env
file in the root directory and add:
MONGO_URI=your_mongodb_connection_string
PORT=3000
- Start the server:
npm start
Method | Endpoint | Description |
---|---|---|
GET | /api/v1/tasks | Get all tasks with filtering options |
POST | /api/v1/tasks | Create a new task |
GET | /api/v1/tasks/:id | Get a single task |
PATCH | /api/v1/tasks/:id | Update a task |
DELETE | /api/v1/tasks/:id | Delete a task |
The GET /api/v1/tasks endpoint supports the following query parameters:
page
: Page number for pagination (default: 1)limit
: Number of items per page (default: 10)sort
: Sort field (default: "createdAt")fields
: Select specific fieldsnumericFilters
: Apply numeric filters (>, <, >=, <=)search
: Search in specific fields
The API returns responses in a consistent format:
{
"isSuccess": true,
"data": [],
"page": 1,
"limit": 10,
"total": 0,
"totalPages": 0,
"hasNext": false,
"hasPrevious": false
}
The project includes a frontend interface with the following features:
- Task listing with completion status
- Add new tasks
- Edit existing tasks
- Delete tasks
- Responsive design
- Success/Error notifications
The API uses conventional HTTP response codes:
- 200: Success
- 201: Created
- 400: Bad Request
- 404: Not Found
- 500: Server Error
βββ app.js # Application entry point
βββ controllers/ # Route controllers
βββ middleware/ # Custom middleware
βββ models/ # Database models
βββ public/ # Frontend assets
βββ routes/ # API routes
βββ utils/ # Utility functions
βββ db/ # Database connection
- Express.js
- MongoDB with Mongoose
- CORS
- dotenv
- HTTP Status Codes
- Frontend: HTML5, CSS3, JavaScript
- Axios for API calls