Skip to content

E-Commerce App with REST API | Node | MongoDB | Advanced Authentication

Notifications You must be signed in to change notification settings

Gichbuoy/E-Commerce-Backend-API

Repository files navigation

E-Commerce Backend API

  • This is a backend API for an E-Commerce platform built using Node.js. It provides various endpoints for managing products, orders, users, and authentication.

Features

  • Product Management: CRUD operations for managing products.
  • Order Management: Create, read, update, and delete orders.
  • User Management: Register, login, and manage user accounts.
  • Authentication: JWT-based authentication for securing API endpoints.
  • Validation: Input validation and error handling.
  • Authorization: Role-based access control for restricting endpoints based on user roles.
  • Database: Integration with MongoDB for data storage.

Technologies Used

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • JSON Web Tokens (JWT) for authentication
  • bcrypt for password hashing
  • Helmet for security headers

Installation

  1. Clone the repository:
git clone https://github.com/Gichbuoy/E-Commerce-Backend-API.git
  1. Navigate to the project directory:
cd E-Commerce-Backend-API
  1. Install dependencies
npm install
  1. Set up environment variables by creating a .env file and adding the following variables:
PORT=3000
MONGOCOMPASS=<your-mongodb-uri>
JWT_SECRET=<your-jwt-secret>
  1. Start the server
npm start

Usage

Once the server is running, you can access the API endpoints using tools like Postman or Insomnia or directly from the Frontend application.

Screenshots

Connection to mongoDB

Screenshot1

User Login

Screenshot1

Registering new User

Screenshot1

Blocking a User

Screenshot1

Refresh Token for Authentication

Screenshot1

Create new Product

Screenshot1

Declare the data schema for MongoDB Model

Screenshot1

Products fetched from mongoDB Compass

Screenshot1

Get Products by ID

Screenshot1

Get All Products

Screenshot1

API Endpoints

For detailed information about the available endpoints, refer to the API Documentation.

Authentication

Authentication is required for certain endpoints. To authenticate, include a JWT token in the request headers:

To obtain a JWT token, you must first register as a user and then login using your credentials.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

E-Commerce App with REST API | Node | MongoDB | Advanced Authentication

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published