- A NodeJS web server created by Express that logs each request with Morgan.
- The web server communicates in memory database created with an array that holds JSON data.
- The array consists of a market inventory which can be found under data folder.
- In order to send request you need to supply a Bearer Token
But first of all; for the back-end, install the dependencies once via the terminal.
npm install
Run the server for Node. It listens on port 3000.
npm start
If you want to enable nodemon Run the development-server for Node.
npm dev
- in order to test via the terminal
curl -X GET http://localhost:3000/ -H "Authorization: Bearer 589b00de-9062-4fd3-8e01-6d3a49d877d1"
or simply via Postman choose Bearer Token under Authorization page and fill token cell with public token.
If you do not give an authorization server responds with code 401
Following endpoints are available:
- GET http://localhost:3000/
- GET http://localhost:3000/inventory/
- GET http://localhost:3000/inventory/:id
- PUT http://localhost:3000/inventory/:id
- PATCH http://localhost:3000/inventory/:id
- POST http://localhost:3000/inventory/
- DELETE http://localhost:3000/inventory/:id
- for the following endpoint PUT or PATCH http://localhost:3000/inventory/5
- send this as body
{
"quantity": 10,
"price": 99
}
- for the following endpoint POST http://localhost:3000/inventory/5
- send this JSON as body since POST requests expects
{
"name": "energy drink",
"category": "Drinks",
"quantity": 120,
"price": 15
}
- You do not need to give ID number since application itself increments the product ID
- If you send ID number with POST requests, web server will ignore and latest product ID increments for new product.