/node-express-mongodb-typescript-ecom-social-rest-api

An open-source RESTful API developed using NodeJS, Express, MongoDB and TypeScript that helps you to integrate User Authentication, E-commerce management and Social Media Post Management in your application with Filter, pagination, Sort and Search API

Primary LanguageTypeScriptMIT LicenseMIT

Saddam-rest-api

Free Open source REST API built with | Nodejs + Express + Mongodb ⚡️ Made with developer experience first Prettier + VSCode setup.

  • C.R.U.D, Filter, Paginate, Sort and Search API

Table of contents

Author

Technologies

  • Node.js
  • Express
  • MongoDB
  • JSON Web Token (JWT)
  • bcryptjs
  • Heroku Hosting

Demo

Testing Email: testverstion@gmail.com

Testing Password: 12345test

Features

(Users)
  • Complete user authentication
  • Users can sign in
  • Users can sign out
  • Users can verify email
  • Users can Change Password
  • View all products
  • View products detail
  • Filter products by category
  • Search for products
  • Add products to their basket
  • Checkout total payment
  • Checkout order page
  • Products pagination
(Admin)
  • Complete Admin Authorization
  • Add products
  • Update products
  • Delete products
  • Limit Products
  • Add Users
  • Update Users
  • Delete Users
  • Update User Role

API_Reference

Get all products

  GET https://saddam-rest-api.herokuapp.com/api/v1/products
Parameter Type Description
limit number default= 100
category string default= All Products
page number default= 1
search string search string
sortBy string default= createdAt
OrderBy string default= desc

example (Paginate - Sort - Filter - Full-text search

  GET https://saddam-rest-api.herokuapp.com/api/v1/products?page=1&limit=99&sortBy=createdAt&OrderBy=desc&filterBy=category&category=Sports
  GET   https://saddam-rest-api.herokuapp.com/api/v1/products?page=2&limit=99&sortBy=createdAt&OrderBy=desc&filterBy=category&category=Jewelery
  GET   https://saddam-rest-api.herokuapp.com/api/v1/products?page=2&limit=99&sortBy=createdAt&OrderBy=desc&filterBy=category&category=Books&search=nodejs

Get single product

  GET https://saddam-rest-api.herokuapp.com/api/v1/products/${id}
Parameter Type Description
id string Required. Id of product to fetch

Add new product (Only admins)

  POST https://saddam-rest-api.herokuapp.com/api/v1/admin/products
Parameter Type Description
name string Required. product name
price number Required. product price
description string Required. product description
productImage img Required. product Image
category string Required. product category
count number Optional. default value = 1
stock string Optional. default value = 'in stock - order soon'

Update product (Only admins)

  PATCH https://saddam-rest-api.herokuapp.com/api/v1/admin/products/${id}
Parameter Type Description
id string Required. Id of product to update
token string Required. JWT token pass in headers

Delete product (Only admins)

  DELETE https://saddam-rest-api.herokuapp.com/api/v1/admin/products/${id}
Parameter Type Description
id string Required. Id of product to delete
token string Required. JWT token pass in headers

User signup

  POST https://saddam-rest-api.herokuapp.com/api/v1/auth/signup
Parameter Type Description
firstName string Required.
lastName string Required.
familyName string Optional.
email string Required.
password string Required.
confirmPassword string Required.
gender string Optional.
dateOfBirth string Optional.
acceptTerms boolean Required.
mobileNumber number Optional.
nationality string Optional.
favoriteAnimal string Optional.
address string Optional.
bio string Optional.
jobTitle string Optional.
  After signup you will receive email to verify your account

User Login

  POST https://saddam-rest-api.herokuapp.com/api/v1/auth/login
Parameter Type Description
email string Required.
password string Required.

User Verify Email

  POST https://saddam-rest-api.herokuapp.com/api/v1/auth/verify-email`,
Parameter Type Description
userId string Required.
token string Required.

Environment

  • To run this project, you will need to add the following environment variables to your .env file (check environment.config.js file for more examples)

  • MONGODB_CONNECTION_STRING

  • TOKEN_SECRET

  • WEBSITE_URL

  • API_VERSION ="v1"

  • JWT_EXPIRE_TIME

  • SEND_GRID_API_KEY

  • ADMIN_SEND_GRID_EMAIL

  • ADMIN_ROLE

  • ADMIN_EMAIL

  • NODE_ENV = 'development'

  • CLIENT_URL

  • ACCESS_TOKEN_SECRET_KEY

  • REFRESH_TOKEN_SECRET_KEY

  • ACCESS_TOKEN_KEY_EXPIRE_TIME

  • REFRESH_TOKEN_KEY_EXPIRE_TIME

Contributing

Contributions are always welcome!

Deployment

To deploy this project on Heroku Flow the Flowing documentation Deploying Node.js Apps on Heroku

Related_Projects

Blog API built with | Nodejs + Express + Mongodb

Twitter API built with | Nodejs + Express + Mongodb

Netflix API built with | Nodejs + Express + Mongodb

Support

For support, email saddamarbaas@gmail.com.

Feedback

If you have any feedback, please reach out to me at saddamarbaas@gmail.com

Twitter https://twitter.com/ArbaaSaddam/

Linkedin. https://www.linkedin.com/in/saddamarbaa/

Github https://github.com/saddamarbaa

Instagram https://www.instagram.com/saddam.dev/

Facebook https://www.facebook.com/saddam.arbaa

Run_Locally

Clone the project

https://github.com/saddamarbaa/node-express-rest-api

Go to the project directory

  cd node-express-rest-api

Install dependencies

yarn install
# or
npm install

Start the server

  node app.js
  or
  nodemon app.js

Status

Project is: in progress I'm working on it in my free time

Screenshots

Signup Page

image

image

LogIn Page

image

image

Forgot Password Page

image

image

image

Reset Password email Link

image

Reset Password Page

image

image

Update Profile Page

image

Home Page

image

Home Page (Filter by category(Bookks))

image

Home Page (Filter by category(Sports))

image

Home Page (Filter by category(Toys))

image

Home Page (Filter by category(Men's clothing))

image

Home Page (Search Product (Jewelery))

image

Product Detail Page

image

Shopping Cart Page

image

Orders Page

image

Admin Products Page

image

Admin Users Page

image

Admin Users Table Page

image

Admin Add Product Page

image

image

Admin Update Product Page

image

Admin Add User Page

image

image

Admin Update User Page

image