This repository contains a fully functional E-commerce API server built with Node.js and Express.js. It provides authentication, user management, product handling, order processing, and security features. The API uses MongoDB as the database and integrates various middleware and third-party services for enhanced functionality.
- Backend Framework: Express.js
4.21.1
- Database: MongoDB (via Mongoose
8.8.0
) - Security: Helmet
8.0.0
, Express Rate Limit7.4.1
, XSS-Clean0.1.4
, Mongo Sanitize2.2.0
- Auth: JWT
9.0.2
, BcryptJS2.4.3
- File Uploads: express-fileupload
1.5.1
- Logging: Morgan
1.10.0
- Development Tools: Nodemon
3.1.7
- User Authentication & Authorization (JWT, hashed passwords)
- Role-based Access Control (Admin, Customer)
- Product Management (Create, Read, Update, Delete)
- Review & Ratings System
- Order & Checkout Flow (Integrated with Fake Stripe)
- Secure API (Rate limiting, Input sanitization, XSS protection)
- File Upload Handling (For product images)
- Logging & Error Handling
- Node.js (v16 or later recommended)
- MongoDB (Local or Cloud-based like MongoDB Atlas)
-
Clone the repository:
git clone https://github.com/MF-Vv/ECOMMERCE-API-SERVER.git cd ECOMMERCE-API-SERVER
-
Install dependencies:
npm install
-
Create a
.env
file and configure environment variables:MONGO_URL=your_mongodb_connection_string JWT_SECRET=your_jwt_secret COOKIE_SECRET=your_cookie_secret JWT_LIFETIME= 1d NODE_ENV=production
-
Start the development server:
npm run dev
-
Start in production mode:
npm start
For detailed API documentation and testing, visit the Postman collection: Postman API Documentation
This API is deployed on Render:
https://ecommerce-api-server-041g.onrender.com
🚨 Free-tier Limitation: Since this API is hosted on a free Render account, the server may spin down due to inactivity, causing delays of up to 50 seconds when handling requests. Consider using a paid plan for better performance.
Happy Coding! 🚀