React frontend with node js backend Exam
React Webshop
Unfortunately, the modules used in this project are no longer supported. However, you can find the source code here:
For this project, we utilized SQL for the database, Node.js as the backend, and React with Redux for the frontend. The design was flexible, and I chose to create a straightforward item store using Bootstrap for styling.
API Endpoints for the backend service
Routes
Root Endpoint
- GET
/
- Description: Returns a simple message indicating that the REST API is operational.
- Response:
<p>REST API</p>
Products
- GET
/products
- Description: Retrieves a list of products.
- Response: JSON array of products.
Order
- POST
/order
- Description: Submits a new order.
- Request Body: Must include the following fields:
user.firstName
(string): First name of the user.user.lastName
(string): Last name of the user.user.street
(string): Street address.user.number
(string): Street number.user.postalCode
(string): Postal code.user.city
(string): City.user.telephone
(string): Telephone number.user.totalPrice
(string): Total price of the order.user.email
(string): Email address (must be a valid email).products
(array): List of products in the order.
- Validation:
- All fields except
products
must not be empty. user.email
must be a valid email address.
- All fields except
- Response:
- 422 Unprocessable Entity: Returns validation errors if any fields are missing or invalid.
- 200 OK: If the order is successfully processed.
Order Confirmation
- GET
/order/:id([0-9]{1,10})
- Description: Retrieves the confirmation details of a specific order by its ID.
- Parameters:
id
(integer): Order ID (up to 10 digits).
- Response: JSON object with order details.
All Orders
- GET
/orders
- Description: Fetches a list of all orders.
- Response: JSON array of orders.
This post is licensed under
CC BY 4.0
by the author.