Shreyas582 / node-restful-api

RESTful API in NodeJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node RESTful API

A RESTful API in NodeJS for a simple shop app.

MongoDB Setup

Connect to MongoDB. Copy connection URL.

Environment Variables

To run this project, you will need to add the following environment variables to your nodemon.json file

{
    "env": {
        "MONGO_ATLAS_URI": "",
        "JWT_KEY": ""
    }
}

Paste the connection URL in MONGO_ATLAS_URI field and use a random string as JWT_KEY.

Run Locally

Clone the project

  git clone https://github.com/Shreyas582/node-restful-api

Go to the project directory

  cd node-restful-api

Install dependencies

  npm install

Start the server

  npm run start

API Reference

Signup User

  POST /user/signup
{
    "email": "",
    "password": ""
}

Login User

  POST /user/login
{
    "email": "",
    "password": ""
}

Delete User

  DELETE /user/:userID
Parameter Type Description
userID string Required. ID of user

Get all products

  GET /products

Add Single Product

  POST /products
Form-Data Type Description
name string Required. Product name
price string Required. Product price
productImage file Required. Product image file

Get Single Product

  GET /products/:productID
Parameter Type Description
productID string Required. ID of product

Update Single Product [Auth Required]

  PATCH /products/:productID
Parameter Type Description
productID string Required. ID of product

Delete Single Product [Auth Required]

  DELETE /products/:productID
Parameter Type Description
productID string Required. ID of product

Get All Orders [Auth Required]

  GET /orders 

Create Order [Auth Required]

  POST /orders 
{
    "quantity": <int>,
    "productID": ""
}

Get Single Order [Auth Required]

  GET /orders/:orderID
Parameter Type Description
orderID string Required. ID of order

Delete Single Order [Auth Required]

  DELETE /orders/:orderID
Parameter Type Description
orderID string Required. ID of order

Acknowledgements

About

RESTful API in NodeJS

License:MIT License


Languages

Language:JavaScript 100.0%