Skip to content

ArtuTerra/taskman

Repository files navigation

Taskman

Status GitHub Issues GitHub Pull Requests License

Task Manager Application

📝 Table of Contents

🧐 About

This is a task manager REST API made by me (this is me) using Laravel 11, it was a task assigned to me as a test of my skills but also to practice and learn from the experience. Taskman is an aplication made to be easy to use but still very useful, this part of the project is only the back-end part of the whole. You can access the front end clicking here

Special thanks to all my friends and family that supported me on my journey so far, and to my co-workers for helping out whenever i asked.

🏁 Getting Started

Prerequisites

Before starting the installation, make sure that your local machine has PHP 8.3 and Composer installed. It is also recomended you have a MySQL Ver 8.0.39 or higher database setup for the project. Useful links: PHP Installation on Windows PHP Installation on macOS PHP Installation on Linux

Composer installation

MySQL Installation

If you are developing on macOS or Windows, you could try Laravel Herd to quickly install PHP, Composer, Node and NPM in minutes.

Installing

It's very simple to install this project, follow the step by step below to get a development env running:

  • First step: Git Clone https://github.com/ArtuTerra/taskman.git
  • Second Step: cd taskman
  • Third Step: composer install (Make sure you have installed composer-setup in your device)
  • Forth Step: cp .env.example .env to copy the .env.example and create a new .env
  • Fifth Step: Configure the .env file for databse connection and go to mysql server and create a desired database
  • Sixth Step: Execute php artisan key:generate command to generate your laravel key
  • Seventh Step: php artisan jwt:secret to generate your JWT auth secret token in your .env
  • Eighth Step: Run the migrations to create the tables in the database: php artisan migrate
  • Ninth Step: Execute the command php artisan serve to run the app
  • Tenth Step Import the taskman.insomnia_collection.json file to Insomnia software (Optional)

🎈 Usage

The instructions to use the REST API of the Taskman application is described below.

Auth Routes

Register into the application

Request

POST /api/register

curl --request POST \
--url http://127.0.0.1:8000/api/register \
--header 'Accept: application/json' \
--header 'Content-Type: multipart/form-data' \
--form name=arthur \
--form [email protected] \
--form password_confirmation=password1234 \
--form password=password1234

Response

< HTTP/1.1 201 Created
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Fri, 09 Aug 2024 11:02:42 GMT
< Content-Type: application/json
< Vary: Origin

{"message":"Success!"}

Login into the application

Request

POST /api/login

curl --request POST \
--url http://127.0.0.1:8000/api/login \
--header 'Accept: application/json' \
--header 'Content-Type: multipart/form-data' \
--form [email protected] \
--form password=password1234

Response

< HTTP/1.1 200 OK
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Fri, 09 Aug 2024 11:23:22 GMT
< Content-Type: application/json
< Vary: Origin

{"id":9,"name":"arthur","email":"[email protected]","access_token":"<your_token>","expires_in":60}

Logout of the application

Request

POST /api/logout

curl --request POST \
--url http://127.0.0.1:8000/api/logout \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \

Response

< HTTP/1.1 204 No Content
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Fri, 09 Aug 2024 11:54:40 GMT
< Vary: Origin

Get current user data

Request

GET /api/me

curl --request GET \
--url http://127.0.0.1:8000/api/me \
--header 'Authorization: Bearer <your_token>' \
--header 'accept: application/json'

Response

< HTTP/1.1 200 OK
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Fri, 09 Aug 2024 11:55:47 GMT
< Content-Type: application/json
< Vary: Origin

{"id":9,"name":"arthur","email":"[email protected]"}

Refresh token

Request

POST /api/refresh

curl --request POST \
--url http://127.0.0.1:8000/api/refresh \
--header 'Accept: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vMTI3LjAuMC4xOjgwMDAvYXBpL2xvZ2luIiwiaWF0IjoxNzIzMjA0NTQ1LCJleHAiOjE3MjMyMDgxNDUsIm5iZiI6MTcyMzIwNDU0NSwianRpIjoiNEtMelpJb2oxdk1EU3NhYSIsInN1YiI6IjkiLCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.t5N1hsrGAGbUXIswFuBUcGL8Mt_g1Lpf-sWUjjPyTHk' \
--header 'User-Agent: insomnia/9.3.1'

Response

< HTTP/1.1 200 OK
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Fri, 09 Aug 2024 11:56:49 GMT
< Content-Type: application/json
< Vary: Origin

{"id":9,"name":"arthur","email":"[email protected]","access_token":"<your_token>","expires_in":60}

Task Routes

Get list of all tasks

Request

GET /api/tasks

curl --request GET \
--url http://127.0.0.1:8000/api/tasks \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \

Response

< HTTP/1.1 200 OK
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Thu, 08 Aug 2024 19:32:19 GMT
< Content-Type: application/json
< Vary: Origin

[
    {
        "id": 0,
	    "title": "",
	    "description": "",
	    "completed": false,
	    "creator_id": 0,
    },
    {...},
]

Get list of tasks with assigned users

Request

GET /api/tasks/assigns

curl --request GET \
--url http://127.0.0.1:8000/api/tasks/assigns \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \

Response

< HTTP/1.1 200 OK
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Thu, 08 Aug 2024 19:32:19 GMT
< Content-Type: application/json
< Vary: Origin

[
    {
        "id": 0,
	    "title": "",
	    "description": "",
	    "completed": false,
	    "creator_id": 0,
	    "assigned_users": [
            {
                "id": 0,
			    "name": "user name",
			    "email": "user email",
			    "pivot": {
				    "task_id": 0,
				    "user_id": 0
                }
            }
        ]
    },
    {...},
]

Create a new Task

Request

POST /api/task

curl --request POST \
--url http://127.0.0.1:8000/api/tasks \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \
--header 'Content-Type: application/json' \
--data '{
    "title": "Task Title",
    "description": "Task Description"
}'

Response

< HTTP/1.1 201 Created
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Thu, 08 Aug 2024 20:05:31 GMT
< Content-Type: application/json
< Vary: Origin

{"title":"Task Title","description":"Task Description","completed":false,"creator_id":1,"id":69}

Get Task by id

Request

GET /task/{id}

curl --request GET \
--url http://127.0.0.1:8000/api/tasks/69 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \

Response

< HTTP/1.1 200 OK
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Thu, 08 Aug 2024 20:14:31 GMT
< Content-Type: application/json
< Vary: Origin

{"id":69,"title":"Task Title","description":"Task Description","completed":false,"creator_id":1,"assigned_users":[]}

Update a task's information

Request

PUT /task/{id}

curl --request PUT \
--url http://127.0.0.1:8000/api/tasks/69 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \
--header 'Content-Type: application/json' \
--data '{
    "title": "New name",
    "description": "New description!",
    "completed": true
}'

Response

< HTTP/1.1 200 OK
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Thu, 08 Aug 2024 20:23:31 GMT
< Content-Type: application/json
< Vary: Origin

{"id":69,"title":"New name","description":"New description!","completed":true,"creator_id":5,"assigned_users":[]}

Delete a task

Request

DELETE /task/{id}

curl --request DELETE \
--url http://127.0.0.1:8000/api/tasks/69 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \

Response

< HTTP/1.1 204 No Content
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Thu, 08 Aug 2024 20:25:51 GMT
< Vary: Origin

User Routes

Get a list with all users

Request

GET /api/users

curl --request GET \
--url http://127.0.0.1:8000/api/users \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \

Response

< HTTP/1.1 200 OK
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Fri, 09 Aug 2024 12:07:15 GMT
< Content-Type: application/json
< Vary: Origin

[
    {
        "id": 1,
        "name": "arthur",
        "email": "[email protected]"
    },
    {...},
]

Assign user(s) to a task

Request

POST /api/tasks/assign/{task id}

curl --request POST \
--url http://127.0.0.1:8000/api/tasks/assign/69 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \
--header 'Content-Type: application/json' \
--data '{
    "user_ids":[1,2]
}'

Response

< HTTP/1.1 200 OK
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Fri, 09 Aug 2024 12:15:18 GMT
< Content-Type: application/json
< Vary: Origin

{
    "id": 69,
    "title": "New name",
    "description": "New description!",
    "completed": false,
    "creator_id": 1,
    "assigned_users": [
        {
            "id": 1,
            "name": "arthur",
            "email": "[email protected]",
            "pivot": {
                "task_id": 69,
                "user_id": 1
            }
        },
        {
            "id": 2,
            "name": "Text",
            "email": "[email protected]",
            "pivot": {
                "task_id": 69,
                "user_id": 2
            }
        }
    ]
}

Remove assigned user(s)

Request

DELETE /api/tasks/assign/{task id}

curl --request DELETE \
--url http://127.0.0.1:8000/api/tasks/assign/69 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <your_token>' \
--header 'Content-Type: application/json' \
--data '{
    "user_ids":[2]
}'

Response

< HTTP/1.1 200 OK
< Host: 127.0.0.1:8000
< Connection: close
< X-Powered-By: PHP/8.3.9
< Cache-Control: no-cache, private
< Date: Fri, 09 Aug 2024 12:21:02 GMT
< Content-Type: application/json
< Vary: Origin

{
    "id": 69,
    "title": "New name",
    "description": "New description!",
    "completed": false,
    "creator_id": 5,
    "assigned_users": [
        {
            "id": 1,
            "name": "Test User",
            "email": "[email protected]",
            "pivot": {
                "task_id": 69,
                "user_id": 1
            }
        }
    ]
}

⛏️ Built Using

🎉 Acknowledgements

About

Projeto de gerenciamento de tarefas

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published