A Node.js/Express.js RESTful API for a store managing system, where one can create, read, update and delete informations about products and sales in a MySQL database.
It uses a model-service-controller architecture, and has unit tests coverage, that were made using Mocha, Chai and Sinon.
Data validation on the request side is made using JOI library.
- Node.js
- Express.js
- Express Async Errors
- JOI
- Mocha
- Chai
- Sinon
- Docker
- MySQL
The full API documentation can be accessed through the route /docs
/products
-
GET: List all products
-
POST: Create a new product in the database
- It requires a JSON object to be passed to the request, with a name (string with a minimum of 5 characters).
{
"name": "Product name"
}
/products/search?q=
- GET: Searches for products with matching name, passed as a query
URL EXAMPLE: /products/search?q=PartOfProductName
/products/:id
-
GET: List product by id
-
PUT: Edit a specific product by its id
- It expects a JSON object to be passed to the request, with a name (string with a minimum of 5 characters).
{
"name": "Product name"
}
- DELETE: Remove a product by its id
/sales
-
GET: List all sales
-
POST: Create a new sale in the database
- It requires an array of objects to be passed to the request, with the following format:
[
{
"productId": 1,
"quantity": 1
},
{
"productId": 2,
"quantity": 5
}
]
/sales/:id
-
GET: List a sale by id
-
PUT: Edit a sale in the database by its id
- It requires an array of objects to be passed to the request, with the following format:
[
{
"productId": 1,
"quantity": 1
},
{
"productId": 2,
"quantity": 5
}
]
- DELETE: Remove a sale by its id