Technologies • Getting Started • API Endpoints • Contribute
This is a simple API created for a fictitious food company specialized only in delivery.
- Java
- Spring
- H2 Database
These are the requirements you will need to run the project:
- OpenJDK 17+
- A REST Client to run HTTP requests such as Postman
git clone https://github.com/nicolasperussi/script-burger-server.git
Use the .env.example
as reference to create your configuration file .env
with your JWT secret key.
JWT_SECRET=
You may open the project using your IDE of choice and run it normally, or you can follow the steps below to run it directly from the terminal.
Make sure you have JAVA_HOME set up correctly in your system's Environment Variables.
cd script-burger-server
./mvnw spring-boot:run
These are the available endpoints in this API:
route | description |
---|---|
POST /auth/register | registers a new user - see details |
POST /auth/login | authenticate a user - see details |
REQUEST
{
"name": "John Doe",
"email": "[email protected]",
"password": "test1234",
"phone": "999999999"
}
REQUEST
{
"email": "[email protected]",
"password": "test1234"
}
RESPONSE
{
// This is a JWT token signed with the
// secret you provided on the .env file
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY3JpcHRidXJnZXItYXBpIiwic3ViIjoiYWRtaW5AYWRtaW4uY29tIiwiZXhwIjoxNzA1NzEyNTI2fQ.BhBb3FiDnd3eF2L4purdjAN9WIk4zBC-Tommg5fz2xg",
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"phone": "999999999",
"role": "CLIENT",
"address": [{ "cep": "01001-000", "street": "Praça da Sé", "number": "0" }],
"username": "[email protected]"
}
}
route | description |
---|---|
GET /products | fetch all products - see details |
GET /products/:id | fetch product by id - see details |
POST /products | create new product - see details |
RESPONSE
[
{
"id": 1,
"name": "JavaScript Burger",
"description": "O JavaScript Burger é feito com 100% de carne bovina, alface crocante, tomate fresco, cebola suavemente temperada, picles em conserva e queijo derretido. É uma combinação deliciosa e suculenta, perfeita para satisfazer o seu desejo por hambúrguer. ",
"slug": "javascript-burger",
"overview": "Hambúrguer favorito de todos os tempos",
"price": 20.99,
"category": "SANDWICH"
}
// and all the other products
]
{
"id": 7,
"name": "PHP Bacon Cheeseburger",
"description": "O PHP Bacon Cheeseburger é feito com 100% de carne bovina, queijo cheddar cremoso e delicioso bacon crocante. Este hambúrguer clássico é perfeito para quem adora um sabor defumado e suculento.",
"slug": "php-bacon-cheeseburger",
"overview": "Hambúrguer clássico com bacon",
"price": 23.99,
"category": "SANDWICH"
}
REQUEST
This is a multipart/form-data
request. These are the parameters:
name: string;
description: string;
overview: string;
price: number;
category: SANDWICH | SIDE | DESSERT | DRINK;
image: file;
route | description |
---|---|
GET /orders | fetch all orders - see details |
GET /orders/user/:id | fetch product by client id - see details |
POST /orders | place new order - see details |
PATCH /orders/:id | advance order to next step - see details |
PATCH /orders/cancel/:id | cancel order - see details |
RESPONSE
Click here to show
[
{
"id": 1,
"moment": "2024-01-19T03:22:18Z",
"status": "WAITING",
"client": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"phone": "999999999",
"role": "CLIENT",
"address": [
{ "cep": "01001-000", "street": "Praça da Sé", "number": "0" }
],
"username": "[email protected]"
},
"items": [
{
"quantity": 2,
"totalPrice": 22.99,
"product": {
"id": 2,
"name": "Python Burger",
"description": "O Python Burger é feito com 100% de carne bovina, queijo cheddar derretido, cebolas crocantes e molho BBQ com sabor agridoce. Essa combinação de sabores é uma verdadeira explosão para o paladar. ",
"slug": "python-burger",
"overview": "Explosão de sabor agridoce de churrasco",
"price": 22.99,
"category": "SANDWICH"
}
}
],
"totalPrice": 45.98
}
// and other orders
]
RESPONSE
Click here to show
[
{
"id": 1,
"moment": "2024-01-19T03:22:18Z",
"status": "WAITING",
"items": [
{
"quantity": 2,
"totalPrice": 22.99,
"product": {
"id": 2,
"name": "Python Burger",
"description": "O Python Burger é feito com 100% de carne bovina, queijo cheddar derretido, cebolas crocantes e molho BBQ com sabor agridoce. Essa combinação de sabores é uma verdadeira explosão para o paladar. ",
"slug": "python-burger",
"overview": "Explosão de sabor agridoce de churrasco",
"price": 22.99,
"category": "SANDWICH"
}
}
],
"totalPrice": 45.98
}
// and other orders
]
REQUEST
{
"userId": 1,
"items": [
{
"productId": 7,
"quantity": 1
},
{
"productId": 2,
"quantity": 1
},
{
"productId": 24,
"quantity": 2
}
]
}
RESPONSE
Click here to show
{
"id": 1,
"moment": "2024-01-19T03:22:18Z",
"status": "IN_PRODUCTION", // this will be update to next step
"client": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"phone": "999999999",
"role": "CLIENT",
"address": [{ "cep": "01001-000", "street": "Praça da Sé", "number": "0" }],
"username": "[email protected]"
},
"items": [
{
"quantity": 2,
"totalPrice": 22.99,
"product": {
"id": 2,
"name": "Python Burger",
"description": "O Python Burger é feito com 100% de carne bovina, queijo cheddar derretido, cebolas crocantes e molho BBQ com sabor agridoce. Essa combinação de sabores é uma verdadeira explosão para o paladar. ",
"slug": "python-burger",
"overview": "Explosão de sabor agridoce de churrasco",
"price": 22.99,
"category": "SANDWICH"
}
}
],
"totalPrice": 45.98
}
RESPONSE
Click here to show
{
"id": 1,
"moment": "2024-01-19T03:22:18Z",
"status": "CANCELED", // this will be changed to CANCELED
"client": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"phone": "999999999",
"role": "CLIENT",
"address": [{ "cep": "01001-000", "street": "Praça da Sé", "number": "0" }],
"username": "[email protected]"
},
"items": [
{
"quantity": 2,
"totalPrice": 22.99,
"product": {
"id": 2,
"name": "Python Burger",
"description": "O Python Burger é feito com 100% de carne bovina, queijo cheddar derretido, cebolas crocantes e molho BBQ com sabor agridoce. Essa combinação de sabores é uma verdadeira explosão para o paladar. ",
"slug": "python-burger",
"overview": "Explosão de sabor agridoce de churrasco",
"price": 22.99,
"category": "SANDWICH"
}
}
],
"totalPrice": 45.98
}
Would like to contribute? Please do so following these steps:
git clone https://github.com/nicolasperussi/script-burger-server.git
git checkout -b feature/NAME
- Follow commit patterns
- Open a Pull Request explaining the problem solved or feature made, if exists, append screenshot of visual modifications and wait for the review!