This Rest Api was built in Node.js and uses PostgreSQL as its database.
PostgreSQL
Clone the application.
https://github.com/hudsonfranca/E-Comerce-API-REST-.git
Install dependencies
yarn install
Edit the .env file with your database connection parameters.
Create the database
yarn sequelize db:create
Create the database tables
npx sequelize-cli db:migrate
Add some initial data for Rest Api to work correctly.
sequelize db:seed:all
Runs the app.
Runs the app in the development mode.
- Create a session
- Get list of customers
- Get a specific customer
- Create a customer
- Delete a customer
- Edit customer data
- Get list of products
- Get a specific product
- Get list of products by name
- Create a product
- Delete a product
- Edit product data
- Get list of brands
- Get a specific brand
- Create a new brand
- Delete a brand
- Edit brand data
- Get list of categories
- Get a specific categorie
- Create a new categorie
- Edit categorie data
- Delete a categorie
- Get list of stock
- Get a specific stock
- Create a stock
- Delete a stock
- Edit stock data
- Get list of payment methods
- Get a specific payment method
- Create a new payment method
- Delete a payment method
- Edit payment method
- Get the list of products that are in the cart
- Add products to cart
- Delete a product from the cart
- Edit the quantity of a product in the cart
- Add a product to your favorites list
- Get the customer's favorite product list
- Create a order
- Get list of orders for each customer
- Get list of orders
- Delete a order
- Get a specific order
- Get order count by status
- Update order status
- Get all images of a product
- Add an image to a product
- Delete a image
- Create a admin
- Get list of admins
- Get a specific admin
- Edit admin data
- Delete a admin
POST /api/sessions
http://localhost:3333/api/sessions
BODY
{
"email_address":"michael@gmail.com",
"password":"12345678"
}
{
"user": {
"id": 6,
"first_name": "Michael",
"last_name": "Jackson",
"email_address": "michael@gmail.com",
"cpf": "01345001022",
"phone_number": "89816543301",
"createdAt": "2020-04-05T15:20:42.411Z",
"updatedAt": "2020-04-05T19:45:56.038Z"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NiwiaWF0IjoxNTg2MTMwNzA3LCJleHAiOjE1ODYyMTcxMDd9.FdaIAn6WoNOgZmEaiVG3T7cmcaV0brelajayFfiXGf4"
}
GET /api/customer?offset=<Your offset>&limit=<Your limit>
http://localhost:3333/api/customer?offset=0&limit=10
{
"count": 2,
"rows": [
{
"id": 2,
"User": {
"first_name": "Michael",
"last_name": "Jackson",
"email_address": "michael@gmail.com",
"cpf": "22222222222",
"phone_number": "27999999999",
"createdAt": "2020-04-01T22:36:33.267Z",
"Addresses": {
"id": 2,
"street_address": "25 Darwin Street",
"city": "New York",
"zip": "23400",
"country": "United states",
"state": "NY"
}
}
}
]
}
GET /api/customer/:id/show
http://localhost:3333/api/customer/2/show
{
"id": 2,
"User": {
"first_name": "Michael",
"last_name": "Jackson",
"email_address": "michael@gmail.com",
"cpf": "22222222222",
"phone_number": "27999999999",
"createdAt": "2020-04-01T22:36:33.267Z",
"Addresses": {
"id": 2,
"street_address": "25 Darwin Street",
"city": "New York",
"zip": "23400",
"country": "United states",
"state": "NY"
}
}
}
POST /api/customer
http://localhost:3333/api/customer
BODY
{
"first_name":"Michael",
"last_name":"Jackson",
"email_address":"michael@gmail.com",
"password":"12345678",
"phone_number":"89816543301",
"cpf":"01345001022",
"customerAddress":{
"street_address":"25 Darwin Street",
"city":"New York",
"zip":"12665",
"country":"United states",
"state":"NY"
}
}
{
"user": {
"id": 6,
"first_name": "Michael",
"last_name": "Jackson",
"email_address": "michael@gmail.com",
"cpf": "01345001022",
"phone_number": "89816543301",
"updatedAt": "2020-04-05T15:20:42.411Z",
"createdAt": "2020-04-05T15:20:42.411Z"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. eyJpZCI6NiwiaWF0IjoxNTg2MTAwMDUyLCJleHAiOjE1ODYxODY0NTJ9._suMxfI7XzDikaOPmBBh4UxVzK64UtdTggLLceECu1Q"
}
DELETE /api/customer/:id
http://localhost:3333/api/customer/6
Status: 200
PUT /api/customer/:id/edit
http://localhost:3333/api/customer/6/edit
BODY
{
"first_name":"Michael",
"last_name":"Jackson",
"email_address":"michael@gmail.com",
"password":"12345678",
"phone_number":"89816543301",
"cpf":"01345001022",
"street_address":"25 Darwin Street",
"city":"New York",
"zip":"12665",
"country":"United states",
"state":"NY"
}
[
{
"id": 6,
"first_name": "Michael",
"last_name": "Jackson",
"cpf": "01345001022",
"email_address": "michael@gmail.com",
"phone_number": "89816543301",
"createdAt": "2020-04-05T15:20:42.411Z",
"updatedAt": "2020-04-05T15:48:49.410Z"
}
]
GET /api/products?offset=<Your offset>&limit=<Your limit>
http://localhost:3333/api/products?offset=0&limit=10
{
"count": 4,
"rows": [
{
"id": 5,
"name": "Produto 3",
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"Images": [
{
"image": "http://localhost:3333/files/bike-1585883570365.jpg",
"id": 7,
"id_product": 5,
"aspect_ratio": "1.9"
}
],
"Brand": {
"id": 7,
"name": "Apple"
},
"Categories": [
{
"id": 7,
"name": "Phones"
}
]
}
]
}
GET /api/products/:id
http://localhost:3333/api/products/6
{
"id": 6,
"name": "Produto de Teste",
"description": "Tesde de quantidade",
"price": "122.90",
"status": true,
"Images": [
{
"image": "http://localhost:3333/files/carro-1585870089081.jpeg",
"id": 6,
"id_product": 6,
"aspect_ratio": "1.44"
}
],
"Brand": {
"id": 7,
"name": "Apple"
},
"Categories": [
{
"id": 7,
"name": "Phones"
}
]
}
GET /api/find/product?name=<Product's name>&offset=<your offset>&limit=<your limit>
http://localhost:3333/api/find/product?name=Teste&offset=0&limit=10
{
"count": 4,
"rows": [
{
"id": 5,
"name": "Produto 3",
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"Images": [
{
"image": "http://localhost:3333/files/bike-1585883570365.jpg",
"id": 7,
"id_product": 5,
"aspect_ratio": "1.9"
}
],
"Brand": {
"id": 7,
"name": "Apple"
},
"Categories": [
{
"id": 7,
"name": "Phones"
}
]
}
]
}
Before creating a product you must create a category and a brand.
POST /api/products
http://localhost:3333/api/products
BODY
{
"name": "Produto 5",
"brand_id": 7,
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"categorie_id":7,
"quantity":10
}
{
"id": 8,
"name": "Produto 5",
"brand_id": 7,
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"updatedAt": "2020-04-05T12:57:23.793Z",
"createdAt": "2020-04-05T12:57:23.793Z"
}
DELETE /api/products/:id
http://localhost:3333/api/products/8
Status: 200
PUT /api/products/:id/edit
http://localhost:3333/api/products/7/edit
BODY
{
"name": "Product",
"brand_id": 7,
"description": "Aspire 5 A515-52-56A8Sistema...",
"price": "3199.00",
"status": true,
"Categories":8
}
[
{
"id": 7,
"name": "Product",
"brand_id": 7,
"description": "Aspire 5 A515-52-56A8Sistema...",
"price": "3199.00",
"status": true,
"createdAt": "2020-04-05T12:40:43.573Z",
"updatedAt": "2020-04-05T19:40:28.349Z"
}
]
GET /api/brands
http://localhost:3333/api/brands
[
{
"id": 7,
"name": "Apple"
},
{
"id": 8,
"name": "Samsung"
}
]
GET /api/brands/:id
http://localhost:3333/api/brands/9
{
"id": 9,
"name": "Microsoft"
}
POST /api/brands
http://localhost:3333/api/brands
BODY
{
"name":"Apple"
}
{
"id": 13,
"name": "Apple",
"updatedAt": "2020-04-05T20:27:28.747Z",
"createdAt": "2020-04-05T20:27:28.747Z"
}
DELETE /api/brands/:id
http://localhost:3333/api/brands/13
Status: 200
PUT /api/brands/:id/edit
http://localhost:3333/api/brands/14
BODY
{
"name":"Apple"
}
[
{
"id": 14,
"name": "Apple",
"createdAt": "2020-04-05T20:39:08.505Z",
"updatedAt": "2020-04-05T20:39:44.323Z"
}
]
GET /api/categories
http://localhost:3333/api/categories
[
{
"id": 7,
"name": "Phones"
},
{
"id": 8,
"name": "Computer"
},
]
GET /api/categories/:id
http://localhost:3333/api/categories/12
{
"id": 12,
"name": "Home"
}
POST /api/categories
http://localhost:3333/api/categories
BODY
{
"name":"Eletronics"
}
{
"id": 13,
"name": "Eletronics",
"updatedAt": "2020-04-05T20:58:53.684Z",
"createdAt": "2020-04-05T20:58:53.684Z"
}
PUT /api/categories/:id/edit
http://localhost:3333/api/categories/13/edit
BODY
{
"name":"Informatica"
}
[
{
"id": 13,
"name": "Home",
"createdAt": "2020-04-05T20:58:53.684Z",
"updatedAt": "2020-04-05T21:35:37.672Z"
}
]
DELETE /api/categories/:id
http://localhost:3333/api/categories/13
Status: 200
GET /api/stock?offset=<Your offset>&limit=<Your limit>
http://localhost:3333/api/stock?offset=0&limit=10
{
"count": 4,
"rows": [
{
"name": "Produto 3",
"Stock": {
"id": 1,
"quantity": 200,
"id_product": 5
}
}
]
}
GET /api/product/:id/stock
:id => Product Id
http://localhost:3333/api/product/5/stock
{
"name": "Product 5",
"Stock": {
"id": 1,
"quantity": 200,
"id_product": 5
}
}
When you create a new product the quantity field will create a stock for the product.
DELETE /api/stock/:id
:id => Stock Id
http://localhost:3333/api/stock/2
Status: 200
PUT /api/stock/:id/edit
:id => stock Id
http://localhost:3333/api/stock/1/edit
BODY
{
"quantity":550
}
[
{
"id": 1,
"quantity": 550,
"id_product": 5,
"createdAt": "2020-04-02T23:12:39.760Z",
"updatedAt": "2020-04-05T22:39:06.940Z"
}
]
GET /api/paymentMethods
http://localhost:3333/api/paymentMethods
[
{
"id": 3,
"name": "Card",
"status": true,
"createdAt": "2020-03-30T01:04:10.232Z",
"updatedAt": "2020-03-30T01:04:10.232Z"
}
]
GET /api/paymentMethods/:id
http://localhost:3333/api/paymentMethods/4
{
"id": 4,
"name": "Card",
"status": true,
"createdAt": "2020-04-01T21:53:44.750Z",
"updatedAt": "2020-04-01T21:53:44.750Z"
}
POST /api/paymentMethods
http://localhost:3333/api/paymentMethods
BODY
{
"name":"Credit card.",
"status":true
}
{
"id": 5,
"status": true,
"name": "Credit card.",
"updatedAt": "2020-04-05T23:17:37.477Z",
"createdAt": "2020-04-05T23:17:37.477Z"
}
DELETE /api/paymentMethods/:id
http://localhost:3333/api/paymentMethods/4
Status: 200
PUT /api/paymentMethods/:id/edit
http://localhost:3333/api/paymentMethods/3/edit
BODY
{
"name":"Credit card",
"status":true
}
[
{
"id": 3,
"name": "Credit card",
"status": true,
"createdAt": "2020-03-30T01:04:10.232Z",
"updatedAt": "2020-04-05T23:42:51.541Z"
}
]
You will need a token to access each customer's cart, create a session or a new customer to get a token.
GET /api/cart
http://localhost:3333/api/cart
HEADER
header => authorization, value => Bearer <Your token>
[
{
"id": 1,
"name": "Notebook Acer Aspire 5 A515-52-56A8 Intel® Core™ i5-8265U 8ªGeração RAM de 8GB SSD de 128 GB HD de 1TB Tela de 15.6 Windows 10",
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"Images": [
{
"image": "http://localhost:3333/files/2-1585778328129.jpg",
"id": 2,
"id_product": 1,
"aspect_ratio": "1.9"
},
{
"image": "http://localhost:3333/files/1-1585778319566.jpg",
"id": 1,
"id_product": 1,
"aspect_ratio": "1.9"
}
],
"cart_products": {
"quantity": 5
}
}
]
You will need a token to add products to a specific customer's cart, create a session or a new customer to get a token.
POST /api/product/:id/cart
http://localhost:3333/api/product/1/cart
HEADER
header => authorization, value => Bearer <Your token>
{
"id": 3,
"id_customers": 6,
"updatedAt": "2020-04-06T00:15:01.819Z",
"createdAt": "2020-04-06T00:15:01.819Z"
}
You will need a token to delete a product from a cart, create a session or a new customer to get a token.
DELETE /api/product/:id/cart
http://localhost:3333/api/product/2/cart
HEADER
header => authorization, value => Bearer <Your token>
Status: 200
You will need a token to edit the quantity of a product that is in a cart, create a session or a new customer to get a token.
PUT /api/product/:id/cart
:id => product Id
http://localhost:3333/api/product/1/cart
HEADER
header => authorization, value => Bearer <Your token>
[
{
"id": 6,
"id_cart": 3,
"id_product": 1,
"quantity": 10,
"createdAt": "2020-04-06T00:15:01.900Z",
"updatedAt": "2020-04-06T01:30:08.908Z"
}
]
You will need a token to add a product to a customer's favorite list, create a session or a new customer to get a token.
POST /api/product/:id/favorites
http://localhost:3333/api/product/1/favorites
HEADER
header => authorization, value => Bearer <Your token>
{
"id": 3,
"id_customers": 6,
"updatedAt": "2020-04-06T01:51:48.327Z",
"createdAt": "2020-04-06T01:51:48.327Z"
}
You will need a token to access a customer's list of favorite products, create a session or a new customer to get a token.
GET /api/favorites
http://localhost:3333/api/favorites
HEADER
header => authorization, value => Bearer <Your token>
{
"Products": [
{
"id": 1,
"name": "Notebook Acer Aspire 5 A515-52-56A8 Intel® Core™ i5-8265U 8ªGeração RAM de 8GB SSD de 128 GB HD de 1TB Tela de 15.6 Windows 10",
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"Images": [
{
"image": "http://localhost:3333/files/2-1585778328129.jpg",
"id": 2,
"id_product": 1,
"aspect_ratio": "1.9"
},
{
"image": "http://localhost:3333/files/1-1585778319566.jpg",
"id": 1,
"id_product": 1,
"aspect_ratio": "1.9"
}
]
}
]
}
To create an order, you will need to add products to the cart, create a payment method and you will also need a token. create a session or a new client to obtain a token.
POST /api/orders
http://localhost:3333/api/orders
HEADER
header => authorization, value => Bearer <Your token>
BODY
{
id_payment_methods: 1,
status: "On hold",
orderAddress: {
"street_address":"25 Darwin Street",
"city":"New York",
"zip":"12665",
"country":"United states",
"state":"NY"
}
}
Status: 200
{
"ok": true
}
To obtain the list of orders for each customer, you will need a token. Create a session or a new customer to get a token.
GET /api/orders
http://localhost:3333/api/orders
HEADER
header => authorization, value => Bearer <Your token>
[
{
"id": 4,
"id_customers": 6,
"id_payment_methods": 6,
"status": "On hold",
"amount": "31990.00",
"created_at": "2020-04-06T02:36:07.950Z",
"Products": [
{
"id": 1,
"name": "Notebook Acer Aspire 5 A515-52-56A8 Intel® Core™ i5-8265U 8ªGeração RAM de 8GB SSD de 128 GB HD de 1TB Tela de 15.6 Windows 10",
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"Images": [
{
"image": "http://localhost:3333/files/2-1585778328129.jpg",
"id": 2,
"id_product": 1,
"aspect_ratio": "1.9"
},
{
"image": "http://localhost:3333/files/1-1585778319566.jpg",
"id": 1,
"id_product": 1,
"aspect_ratio": "1.9"
}
],
"orders_products": {
"quantity": 10
}
}
],
"OrdersAddresse": {
"id": 9,
"street_address": "25 Darwin Street",
"city": "New York",
"zip": "12665",
"country": "United states",
"state": "NY"
},
"Customers": {
"id": 6,
"User": {
"id": 6,
"first_name": "Michael",
"last_name": "Jackson",
"email_address": "michael@gmail.com"
}
}
}
]
To obtain the list of orders you will need a token. Create a session or a new customer to get a token.
GET /api/orders/index?offset=<Your offset>&limit=<Your limit>
http://localhost:3333/api/orders/index?offset=0&limit=10
HEADER
header => authorization, value => Bearer <Your token>
{
"count": 1,
"rows": [
{
"id": 1,
"id_customers": 2,
"id_payment_methods": 3,
"status": "Completed",
"amount": "6398.00",
"created_at": "2020-04-01T23:43:03.243Z",
"Products": [
{
"id": 1,
"name": "Notebook Acer Aspire 5 A515-52-56A8 Intel® Core™ i5-8265U 8ªGeração RAM de 8GB SSD de 128 GB HD de 1TB Tela de 15.6 Windows 10",
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"Images": [
{
"image": "http://localhost:3333/files/2-1585778328129.jpg",
"id": 2,
"id_product": 1,
"aspect_ratio": "1.9"
},
{
"image": "http://localhost:3333/files/1-1585778319566.jpg",
"id": 1,
"id_product": 1,
"aspect_ratio": "1.9"
}
],
"orders_products": {
"quantity": 2
}
}
],
"OrdersAddresse": {
"id": 5,
"street_address": "Rua A n°28 Boa Vista",
"city": "Linhares",
"zip": "7897",
"country": "Brasil",
"state": "ES"
},
"Customers": {
"id": 2,
"User": {
"id": 2,
"first_name": "Hudson",
"last_name": "Silvares França Gama",
"email_address": "hudson@gmail.com"
}
}
}
]
}
DELETE /api/orders/:id
http://localhost:3333/api/orders/4
Status: 200
GET /api/orders/:id/show
http://localhost:3333/api/orders/1/show
{
"id": 1,
"id_customers": 2,
"id_payment_methods": 3,
"status": "Completed",
"amount": "6398.00",
"created_at": "2020-04-01T23:43:03.243Z",
"Products": [
{
"id": 1,
"name": "Notebook Acer Aspire 5 A515-52-56A8 Intel® Core™ i5-8265U 8ªGeração RAM de 8GB SSD de 128 GB HD de 1TB Tela de 15.6 Windows 10",
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"orders_products": {
"quantity": 2
}
}
],
"OrdersAddresse": {
"id": 5,
"street_address": "Rua A n°28 Boa Vista",
"city": "Linhares",
"zip": "7897",
"country": "Brasil",
"state": "ES"
},
"Customers": {
"id": 2,
"User": {
"id": 2,
"first_name": "Hudson",
"last_name": "Silvares França Gama",
"email_address": "hudson@gmail.com"
}
}
}
GET /api/orders/status/:name
http://localhost:3333/api/orders/status/Completed
{
"count": 1,
"rows": [
{
"id": 1,
"id_customers": 2,
"id_payment_methods": 3,
"status": "Completed",
"amount": "6398.00",
"created_at": "2020-04-01T23:43:03.243Z",
"Products": [
{
"id": 1,
"name": "Notebook Acer Aspire 5 A515-52-56A8 Intel® Core™ i5-8265U 8ªGeração RAM de 8GB SSD de 128 GB HD de 1TB Tela de 15.6 Windows 10",
"description": "Aspire 5 A515-52-56A8Sistema OperacionalWindows 10 Home 64 bitsCPU e chipsetIntel® Core™ i5-8265U 8ª geração Quad CoreFrequência: 1,6 GHz a 3,9 GHz (turbo max)6 MB de SmartCacheMemória RAM8 GB (1x8GB) DDR4Até 2400 MHzExpansível a 32...",
"price": "3199.00",
"status": true,
"orders_products": {
"quantity": 2
}
}
],
"OrdersAddresse": {
"id": 5,
"street_address": "Rua A n°28 Boa Vista",
"city": "Linhares",
"zip": "7897",
"country": "Brasil",
"state": "ES"
},
"Customers": {
"id": 2,
"User": {
"id": 2,
"first_name": "Hudson",
"last_name": "Silvares França Gama",
"email_address": "hudson@gmail.com"
}
}
}
]
}
PUT /api/order/:id/edit
http://localhost:3333/api/order/1/edit
BODY
{
"status":"On hold"
}
[
{
"id": 1,
"id_customers": 2,
"id_payment_methods": 3,
"amount": "6398.00",
"status": "On hold",
"createdAt": "2020-04-01T23:43:03.243Z",
"updatedAt": "2020-04-07T00:05:03.175Z"
}
]
GET /api/product/:id/images
:id => product id
http://localhost:3333/api/product/1/images
[
{
"image": "http://localhost:3333/files/1-1585778319566.jpg",
"id": 1,
"id_product": 1,
"aspect_ratio": "1.9"
},
{
"image": "http://localhost:3333/files/2-1585778328129.jpg",
"id": 2,
"id_product": 1,
"aspect_ratio": "1.9"
}
]
Add one image at a time.
GET /api/product/:id/images/:aspect_ratio
:id => Product id
const imageFormData = new FormData();
//imageFile => Your image
imageFormData.append("image", imageFile);
await api.post(`/api/product/1/images/1.2`, imageFormData);
{
"image": "http://localhost:3333/files/bike-1585883570365.jpg",
"id": 7,
"id_product": 1,
"aspect_ratio": "1.9",
"updatedAt": "2020-04-03T03:12:50.462Z",
"createdAt": "2020-04-03T03:12:50.462Z"
}
DELETE /api/images/:id
http://localhost:3333/api/images/7
Status: 200
POST /api/admin
http://localhost:3333/api/admin
BODY
{
"first_name":"Steve",
"last_name":"Jobs",
"email_address":"stevejobs@gmail.com",
"password":"12345678",
"phone_number":"89816543301",
"cpf":"01345001033",
"adminAddress":{
"street_address":"25 Darwin Street",
"city":"New York",
"zip":"12665",
"country":"United states",
"state":"NY"
},
"type":"Boss"
}
{
"user": {
"id": 8,
"first_name": "Steve",
"last_name": "Jobs",
"email_address": "stevejobs@gmail.com",
"cpf": "01345001033",
"phone_number": "89816543301",
"updatedAt": "2020-04-07T23:31:06.588Z",
"createdAt": "2020-04-07T23:31:06.588Z"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6OCwiaWF0IjoxNTg2MzAyMjc1LCJleHAiOjE1ODYzODg2NzV9.9DY_zxKvaPxNT3VCfzzrURFciHPAdNT6QmjL3-AF0kg"
}
GET /api/admin
http://localhost:3333/api/admin
[
{
"id": 8,
"type": "Boss",
"User": {
"first_name": "Steve",
"last_name": "Jobs",
"email_address": "stevejobs@gmail.com",
"cpf": "01345001033",
"phone_number": "89816543301",
"createdAt": "2020-04-07T23:31:06.588Z",
"Addresses": {
"street_address": "25 Darwin Street",
"city": "New York",
"zip": "12665",
"country": "United states",
"state": "NY"
}
}
}
]
GET /api/admin/:id
http://localhost:3333/api/admin/8
{
"id": 8,
"type": "Boss",
"User": {
"first_name": "Steve",
"last_name": "Jobs",
"email_address": "stevejobs@gmail.com",
"cpf": "01345001033",
"phone_number": "89816543301",
"createdAt": "2020-04-07T23:31:06.588Z",
"Addresses": {
"street_address": "25 Darwin Street",
"city": "New York",
"zip": "12665",
"country": "United states",
"state": "NY"
}
}
}
PUT /api/admin/:id/edit
http://localhost:3333/api/admin/8/edit
BODY
{
"first_name":"Hudson 2",
"last_name":"Jobs",
"email_address":"stevejobs0@gmail.com",
"password":"12345678",
"phone_number":"89816543301",
"cpf": "01345001039",
"street_address":"25 Darwin Street",
"city":"RIO",
"zip":"12665",
"country":"United states",
"state":"NY",
"type":"Employe"
}
[
{
"id": 8,
"first_name": "Hudson 2",
"last_name": "Jobs",
"cpf": "01345001033",
"email_address": "stevejobs1@gmail.com",
"phone_number": "89816543301",
"createdAt": "2020-04-07T23:31:06.588Z",
"updatedAt": "2020-04-08T00:08:54.196Z"
}
]
DELETE /api/admin/:id
http://localhost:3333/api/admin/7
Status: 200