The Task Manager API is a RESTful web service that provides endpoints for managing users and tasks.
- Task Manager API
To use the Task Manager API, you can make HTTP requests to the provided endpoints. The base URL for the deployed version is https://hammo-task-manager-api.onrender.com.
To run the Task Manager API locally, follow the steps below.
- Node.js and npm installed on your machine.
- MongoDB server connection details (MONGODB_URL).
git clone /~https://github.com/mohamedabdallah20/task-manager-api.git
cd task-manager-api
npm install
Create a .env file in the root directory of the project and add the following environment variables:
PORT=3000
SENDGRID_API_KEY=your_sendgrid_key
MONGODB_URL=your_mongodb_url
JWT_SECRET=your_jwt_secret
Replace your_sendgrid_key, your_mongodb_url, and your_jwt_secret with your actual values.
npm start
The Task Manager API will start running at http://localhost:3000
.
To run the tests, use the following command:
npm test
you can write your own test cases in test suite /tests
-
Endpoint:
POST /users
-
Description: Creates a new user.
-
Request Body:
{ "name": "John Doe", "email": "john@example.com", "password": "password123" }
-
response
{ "user": { "_id": "user_id", "name": "John Doe", "email": "john@example.com" }, "token": "access_token" }
-
Endpoint:
POST /users/login
-
Description: Logs in an existing user.
-
Request Body:
{ "email": "john@example.com", "password": "password123" }
-
Response:
{ "user": { "_id": "user_id", "name": "John Doe", "email": "john@example.com" }, "token": "access_token" }
- Endpoint:
POST /users/logout
- Description: Logs out the current user.
- Authentication required.
- Endpoint:
POST /users/logoutall
- Description: Logs out the user from all devices.
- Authentication required.
- Endpoint:
GET /users/me
- Description: Retrieves the profile of the authenticated user.
- Authentication required.
-
Endpoint:
PATCH /users/me
-
Description: Updates the profile of the authenticated user.
-
Request Body (optional):
{ "name": "New Name", "age": 30, "password": "newpassword" }
-
Authentication required.
- Endpoint:
DELETE /users/me
- Description: Deletes the profile of the authenticated user.
- Authentication required.
- Endpoint:
POST /users/me/avatar
- Description: Uploads an avatar image for the authenticated user.
- Authentication required.
- Endpoint:
DELETE /users/me/avatar
- Description: Deletes the avatar image of the authenticated user.
- Authentication required.
- Endpoint:
GET /users/:id/avatar
- Description: Retrieves the avatar image of a user by their ID.
-
Endpoint:
POST /tasks
-
Description: Creates a new task.
-
Request Body:
{ "description": "Task description" }
-
Authentication required.
-
Response
{ "_id": "task_id", "description": "Task description", "completed": false, "owner": "user_id" }
- Endpoint:
GET /tasks
- Description: Retrieves tasks owned by the authenticated user.
- Authentication required.
- Endpoint:
GET /tasks/:taskId
- Description: Retrieves a task by its ID.
- Authentication required.
-
Endpoint:
PATCH /tasks/:id
-
Description: Updates a task by its ID.
-
Request Body (optional):
{ "description": "New task description", "completed": true }
-
Authentication required.
- Endpoint:
DELETE /tasks/:id
- Description: Deletes a task by its ID.
- Authentication required.
The Task Manager API is deployed at https://hammo-task-manager-api.onrender.com.
The Task Manager API uses the following dependencies:
- Express: Fast, flexible web framework for Node.js.
- MongoDB: NoSQL database used for storing user and task data.
- Multer: Middleware for handling file uploads.
- Sharp: Image processing library for resizing and formatting images.
If you'd like to contribute to the development of the Task Manager API, feel free to fork the repository and submit pull requests.
To run the Task Manager API in a Docker container, follow these steps:
- Docker installed on your machine.
-
Clone the repository:
git clone /~https://github.com/mohamedabdallah20/task-manager-api.git
-
Navigate to the project directory:
cd task-manager-api
-
Build the Docker image by Docker compose in production mood:
docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d --build
This command will create three Docker images named
task-manager-node-app , mongo-express , mongo
and three Docker containers.
-
Once the container is running, you can access the Task Manager API at:
http://localhost:8888
-
you can access the MongoDB UI:
http://localhost:8081
-
the stopped the containers, use:
docker compose -f docker-compose.yml -f docker-compose-dev.yml down
The Task Manager API is open-source software licensed under the MIT license.