Skip to content

The Express API, powered by Express.js and MongoDB, ensures secure authentication and role-based access control. With user roles (User, Admin, SuperAdmin), it efficiently manages to-do lists and tasks. The API's structure prioritizes scalability and security for robust task management applications.

Notifications You must be signed in to change notification settings

m-ehab2/ToDoAPI

Repository files navigation

ToDoAPI

The ToDoAPI is a RESTful API built with Express.js and MongoDB, providing secure authentication, role-based access control, and robust task management capabilities. It allows users to create, update, and delete to-do lists and individual tasks, with role-specific functionalities for admins and superadmins.

Table of Contents

  1. Introduction
  2. Features
  3. Getting Started
  4. Usage
  5. Routes
  6. Error Handling
  7. Testing
  8. Documentation
  9. Contributing
  10. License

Introduction

The ToDoAPI is designed to facilitate task management for users with different roles. It includes user authentication, role-based access control (RBAC), and CRUD operations for both to-do lists and individual tasks.

Features

  • User registration and login with JWT authentication
  • Role-based access control (User, Admin, SuperAdmin)
  • CRUD operations for user profiles
  • Create, update, and delete to-do lists
  • Manage individual tasks within a list
  • Admin and SuperAdmin functionalities

Getting Started

Prerequisites

Before running the ToDoAPI, ensure you have the following installed:

  • Node.js
  • MongoDB

Installation

  1. Clone the repository:
git clone https://github.com/m-ehab2/ToDoAPI.git
  1. Navigate to the project directory:
cd ToDoAPI
  1. Install dependencies:
npm install

Usage

Authentication

  • Use the /register and /login routes for user registration and login.
  • Include the JWT token received upon login in the Authorization header for authenticated routes.

User Profiles

  • Access and update user profiles using the /profile route.

To-Do Lists

  • Create, update, and delete to-do lists using the /list route.
  • Manage individual tasks within a list using nested routes under /list/:listId/todos.

Admin and SuperAdmin

  • Access admin functionalities using the /Dashboard route (requires Admin or SuperAdmin role).
  • SuperAdmins can perform additional tasks through the /SuperBoard route.

Routes

  • Authentication Routes:

    • /register (POST): User registration.
    • /login (POST): User login.
  • User Routes:

    • /profile (GET, PUT): Access and update user profiles.
  • To-Do List Routes:

    • /list (POST): Create a new to-do list.
    • /list/:listId (GET, PUT, DELETE): Access and manage individual to-do lists.
  • To-Do Routes (Within a List):

    • /list/:listId/todos (GET): Get all to-dos in a list.
    • /list/:listId/todos/:todoId (GET, PUT, DELETE): Access and manage individual to-dos within a list.
  • Admin and SuperAdmin Routes:

    • /Dashboard (GET): Access admin functionalities (requires Admin or SuperAdmin role).
    • /SuperBoard (GET): Access SuperAdmin functionalities.

Error Handling

The API includes comprehensive error handling for various scenarios. Common HTTP error codes are used, along with detailed error messages in the response.

Testing

The project includes unit tests for critical functions and integration tests for API routes. Ensure to run tests to verify the correctness of the implementation.

Documentation

For detailed API documentation, refer to the provided code comments, API routes, and the Postman collection.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

About

The Express API, powered by Express.js and MongoDB, ensures secure authentication and role-based access control. With user roles (User, Admin, SuperAdmin), it efficiently manages to-do lists and tasks. The API's structure prioritizes scalability and security for robust task management applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published