Treez service to model the current inventory, deducting from inventory as orders are created, and adding inventory back if orders are canceled
Kindly review the Postman Documentation for more insight into the API.
- Framework Used: sails.js
- ORM: Waterline
- DB Storage: sails-disk
- Testing: Mocha, supertest (HTTP assertions), Joi (Schema Validation)
- run
cd service
to navigate to the service root directory - run
npm i
to install the required packages
- run
npm test
to execute the tests
- run
npm start
to start the server athttp://localhost:1337
service/api/models
- Model definitions representing database tables/collections. Showing their attributes incuding relationships to other models.service/api/controllers
- Server-side actions for handling incoming requests. Showing validation schemas and requests handling.service/tests
- Tests directoryservice/config/bootstrap.js
- For seeding the app with fake data before sails is lifted.service/config/routes.js
- API Endpoints config
I made a compromise on the choice of datastore. I chose to use sails-disk (more ideal for Development env not Production) to allow easier evaluation setup as no extra DB setup is nessary. However, the datastore of your choice can be used by simply specifying the adapter and url of your database within the service/config/datastore.js
file by replacing the following block of code with your appropriate datastore parameters.
// adapter: 'sails-mysql',
// url: 'mysql://user:password@host:port/database',
In addition to some minor code refactoring, the service could also benefit from detailed logging of all requests and responses to aid debugging process.