Fruity Vice App is a simple monorepo application that has the following directories
- api - handles the RESTful API
- app - handles the UI and consumed the data from the API
- docker (TODO)
- PHP 8.1+
- Node v16+
- NPM v8+
- MySQL 5.6+ or 8
Clone this project https://github.com/benborla/fruit-vice
Follow the following commands:
cd ./api
cp .env.dist .env
composer install
composer run setup
php bin/console fruits:fetch --truncate=false
composer run serve
Follow the following commands:
cd ./app
npm install
cp .env.development .env
npm run dev
- Access the provided URL from
npm run dev
command
Below is the command available for Fruity Vice
Usage: php bin/console fruits:fetch
Command | Description |
---|---|
fruits:fetch | Sync database from API source, optional parameter --truncate={bool} |
Method: GET
Endpoint: /
Parameters:
- page: for pagination, which page should it return
- size: how many rows it should return
- order_by: allowed values are name and family
- search: search criteria
- direction: allowed values are asc and desc
Sample Usage: /?size=5&page=2
Method: GET
Endpoint: /fruit/:id
Parameters: id
Method: POST or PUT
Endpoint: /fruit
Sample Payload:
{
"name": "test_name",
"genus": "test_genus",
"family": "test_family",
"fruitOrder": "test_fruit_order",
"carbohydrates": 0,
"fat": 0,
"protein": 0,
"sugar": 11,
"calories": 1555.1
}
Method: POST or PATCH
Endpoint: /fruit/:id
Parameters: id
Sample Payload:
{
"family": "test_family_updated",
...
}
Only provide the properties that needs to be updated.
Method: DELETE
Endpoint: /fruit/:id
Parameters: id
Method: GET
Endpoint: /favorites
Method: POST
Endpoint: /favorites/:fruitId
Parameter: fruitId
Method: DELETE
Endpoint: /favorite/:fruitId
Parameters: fruitId