For Windows
- Python 2.7 (for microsoft build tools)
- Install Microsoft build tools (to build sqlite using node-gyp)
- Instructions here https://github.com/nodejs/node-gyp#on-windows
- Or install using npm (
npm install --global windows-build-tools)
- Node-gyp (
npm install --global node-gyp)
- Run
npm installto installl dependencies - Run
npm run startto start the local server - Load
http://localhost:8000to test the endpoint. It will display a json result{"message":"University of Moratuwa"}
Get a list of products
{
"message": "success",
"data": [
{
"id": 64,
"productName": "White Basmathi Rice",
"description": "Imported from Pakistan. Oragnically Grown",
"category": "Rice",
"brand": "CIC",
"expiredDate": "2022-09-01",
"manufacturedDate": "2021-12-13",
"batchNumber": "C-984367",
"unitPrice": 450,
"quantity": 500,
"createdDate": "Sun Mar 13 2022"
}
]
}Get products information by product id
{
"message": "success",
"data": {
"id": 64,
"productName": "White Basmathi Rice",
"description": "Imported from Pakistan. Oragnically Grown",
"category": "Rice",
"brand": "CIC",
"expiredDate": "2022-09-01",
"manufacturedDate": "2021-12-13",
"batchNumber": "C-984367",
"unitPrice": 450,
"quantity": 500,
"createdDate": "Sun Mar 13 2022"
}
}To create a new product based on POST data (x-www-form-url-encoded)
{
"productName":"20000 Basmathi Rice",
"description":"White Basmathi Rice imported from Pakistan. High-quality rice with extra fragrance. Organically grown.",
"category":"Rice",
"brand":"CIC",
"expiredDate":"2023.05.04",
"manufacturedDate":"2022.02.20",
"batchNumber":324567,
"unitPrice":1020,
"quantity":200,
"createdDate":"2022.02.24"
}To update products data by id, based on POST data (x-www-form-url-encoded)
{
"productName":"20000 Basmathi Rice",
"description":"Red Basmathi Rice imported from Israel. High-quality rice with extra fragrance. Organically grown.",
"category":"Rice",
"brand":"CIC",
"expiredDate":"2023.05.04",
"manufacturedDate":"2022.02.20",
"batchNumber":324567,
"unitPrice":1020,
"quantity":200,
"createdDate":"2022.02.24"
}To remove a products from the database by products id.
This example is using the curl command line
curl -X "DELETE" http://localhost:8000/api/products/2The result is:
{"message":"deleted","rows":1}