On root
npm install
On api folder
composer install
On project root
npm run dev
On folder api
php -S localhost:8080 -t Public
Copy the .env.example file to .env and fill in the values for the chosen host address.
cp .env.example .env
A config database file is provided in the api folder, in the Config folder, you can change the database configuration there, if you want to use another database.
I've uploaded to the folder postman a exported JSON file with the routes that the api provide, it's simple and straightforward because of the time, but have all working routes are present.
Lint with ESLint
On project root
npm run lint
Don't have a lot of time to work on this project, but I've found some issues that I would like to fix if I had more time.
- Don't have a route for update user.
- Don't have a route for delete user.
- Don't have a route to make a user admin. Need to do it manually on database.
- There some parts at the front end that are only seen by the admin, like the admin page on profile menu.
- The database already have a user with admin privileges, the email is: [email protected] and the password is: administrator.
- I've taken seven days to do this project, but I've worked on it only on weekdays, so I've spent about 40 hours on it.
/users
Authorization: Bearer Token Request Headers: Content-Type application/json
/user
Authorization: Bearer Token Request Headers: Content-Type application/json
user?id=28
user/store
Content-Type application/json
{
"name": "Gabriel D Sousa",
"email": "[email protected]",
"password": "LoremIpsum",
"confirmation": "LoremIpsum"
}
user/update
Authorization: Bearer Token
{
"id": "1",
"name": "Gabriel D. Sousa",
"email": "[email protected]"
}
user/delete
Authorization: Bearer Token
{
"id": 1
}
/types
Content-Type application/json
/type
Authorization: Bearer Token
?id=1
type/store
Authorization: Bearer Token
{
"name": "Alimentício",
"tax": 27
}
type/update
Authorization: Bearer Token
{
"id": 1,
"name": "Estética",
"tax": 10
}
type/delete
Authorization: Bearer Token
{
"id": 2
}
/sales
Authorization: Bearer Token Content-Type application/json
/sale
Authorization: Bearer Token
?id=1
sale/store
Authorization: Bearer Token
{
"chart": "{ {product: 5, quantity:12, value:200, tax:42, total:242}, {product: 7, quantity:2, value:25.98, tax:2.72, total:28.70} }",
"value": "225.98",
"tax": "44.72",
"total": "270.70",
"user_id": 28
}
type/update
Authorization: Bearer Token
{
"id": 12,
"name": "Cuidados pessoais",
"tax": 22
}
type/delete
Authorization: Bearer Token
{
"id": 2
}
/products
Authorization: Bearer Token Content-Type application/json
/product
{
"id": 1
}
product/store
Authorization: Bearer Token
{
"name": "Coke",
"description": "Lorem ipsum dolor amet.",
"value": 3,
"type_id": 2
}
product/update
Authorization: Bearer Token
{
"name": "Coke zero",
"description": "Lorem ipsum.",
"value": 9,
"type_id": 3,
"id": 3
}
product/delete
Authorization: Bearer Token
{
"id": 3
}
login
{
"email": "[email protected]",
"password": "LoremIpsum"
}
logout
Authorization: Bearer Token
{
"email": "[email protected]"
}