Skip to content

A restful NodeJS web API that handles CRUD operation with in memory array database. Each request is logged with Morgan and Express bearer token is applied.

Notifications You must be signed in to change notification settings

fatihkaya13/node-expressjs-restful-arraydb-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

week-3-assignment-fatih-kaya

Express Web Server

  • 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

public key is the following 589b00de-9062-4fd3-8e01-6d3a49d877d1

  • 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. bearer token implementation If you do not give an authorization server responds with code 401

Following endpoints are available:

GET request

Note that you can only modify QUANTITY and PRICE of an item

You cannot edit quantity or price below zero

PUT and PATCH guide

{
    "quantity": 10,
    "price": 99
}

POST guide

{
    "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.
There is an application logic behind this.
You cannot post an inventory if category does not exist in the DB.
You cannot post an inventory if price or category is below zero.

FATİH KAYA

Thank you for reviewing my repo ❤️ ❤️ ❤️

About

A restful NodeJS web API that handles CRUD operation with in memory array database. Each request is logged with Morgan and Express bearer token is applied.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published