- 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.
- 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.
- Node.js
- Express.js
- MongoDB
- Mongoose
- JSON Web Tokens (JWT) for authentication
- bcrypt for password hashing
- Helmet for security headers
- Clone the repository:
git clone https://github.com/Gichbuoy/E-Commerce-Backend-API.git
- Navigate to the project directory:
cd E-Commerce-Backend-API
- Install dependencies
npm install
- 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>
- Start the server
npm start
Once the server is running, you can access the API endpoints using tools like Postman or Insomnia or directly from the Frontend application.
Connection to mongoDB
User Login
Registering new User
Blocking a User
Refresh Token for Authentication
Create new Product
Declare the data schema for MongoDB Model
Products fetched from mongoDB Compass
Get Products by ID
Get All Products
For detailed information about the available endpoints, refer to the API Documentation.
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.
This project is licensed under the MIT License - see the LICENSE file for details.