node v10.14.1 and above
. npm should be also installed automatically along with node.mysql 8.0.15
Once you have node and npm installed from the root of the project
npm install
Ensure that a products database is already created. Install knex globalls to handle database migrations.
npm i knex -g
Now to execute migrations
knex migrate:latest
To rollback migrations
knex migrate:rollback
Application runs on port 3000
npm start
To run end to end tests
npm test
Get all Products
curl --request GET \
--url http://localhost:3000/v1/products
Create a Product
curl --request POST \
--url http://localhost:3000/v1/products \
--header 'content-type: application/json' \
--data '{
"name": "Red Shirt55",
"description": "Red hugo boss shirt555",
"brand": "Hugo Boss",
"tags": [
"red",
"shirt",
"slim fit"],
"category": "apparel"
}'
Get a product by category and with pagination supported by limit and offset
curl --request GET \
--url 'http://localhost:3000/v1/products?category=apparel&limit=5&offset=2'
Add more end to end tests for Get Products to test filtering of results by category and showcasing pagination by limit and offset. Unit tests are missing for the application.
Graceful Shutdown of application. Currently you might have to Ctrl C twice to exist application.
SIGINT Interrupt signal detected and exiting node process now.
Process is terminated
Process is terminated
^CSIGINT Interrupt signal detected and exiting node process now.
Terminated: 15