Backend project for managing a store's inventory with a simple CRUD (Create, Read, Update, Delete). In this project it was possible to put into practice lessons learned with the MSC architecture (Model, Service and Controller), Node JS for code execution, Express JS for the creation of the API that communicates with the database, MySQL to store the data in the database, Mocha/Chai for test development and Sinon JS to stub the functions of the MSC layers
JavaScript, Node JS, MySQL, Express JS, MSC Architecture, Mocha, Chai, Sinon
Products
- Select all products
Method: GET Endpoint: /products
- Select products by ID
Method: GET Endpoint: /products/:id
- Create product
Method: POST Endpoint: /products
Body example: { "name": "example" }
- Update product
Method: PUT Endpoint: /products/:id
Body example: { "name": "new_name_example" }
- Delete product
Method: DELETE Endpoint: /products/:id
- Search product by name
Method: GET Endpoint: /products/search?q={query}
Sales
- Select all sales
Method: GET Endpoint: /sales
- Select sales by ID
Method: GET Endpoint: /sales/:id
- Create sale
Method: POST Endpoint: /sales
Body example: [ { "productId": 1, "quantity": 1 }, { "productId": 2, "quantity":5 } ]
- Update sales
Method: PUT Endpoint: /sales/:id
Body example: [ { "productId": 1, "quantity":10 }, { "productId": 2, "quantity":50 } ]
- Delete sale
Method: DELETE Endpoint: /sales/:id
1 - Clone the project
2 - Enter the directorystore-manager/
3 - Start docker
4 - Run the commanddocker compose up -d
5 - Run the commanddocker exec -it store_manager bash
6 - Run the commandnpm install
inside docker to install
7 - Run the commandnpm run migration
inside docker to create database
8 - Run the commandnpm run seed
inside docker to populate database (if you need to repopulate, use this command again)
9 - Run the commandnpm run debug
inside docker to run application
1 - Do the previous steps up to 6
2 - Run the commandnpm run test:mocha
inside docker