- Introduction
- Features
- Technology Stack
- Installation
- Configuration
- File Structure
- API Endpoints
- Contributing
The E-Shop API is a backend service for an e-commerce application, providing functionalities such as user authentication, product catalog management, and order processing. This API is built using Node.js, Express, MongoDB, and other modern technologies.
- User authentication and authorization
- Admin functionalities to manage users
- Product catalog management (to be implemented)
- Order processing (to be implemented)
- Email verification for user registration
- Backend: Node.js, Express
- Database: MongoDB, Mongoose
- Authentication: JWT
- Email Service: Nodemailer
To get started with the E-Shop API, follow these steps:
- Clone the repository:
git clone https://github.com/Butawantemi/e-shop
cd e-shop- Install dependencies:
npm install- Set up environment variables: Create a .env file in the root directory and add the following variables:
PORT=4000
MONGO_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret
EMAIL=your_email
PASSWORD=your_email_password
API_URL=/api- Start the application:
npm startEnsure you have the following environment variables configured in your .env file:
- PORT: The port on which the server will run.
- MONGO_URI: Your MongoDB connection string.
- JWT_SECRET: Secret key for JWT token generation.
- EMAIL: Email address used for sending verification emails.
- PASSWORD: Password for the email account used for sending emails.
- API_URL: Base URL for the API.
Here is the basic structure of the project:
├── src
│ ├── Config
│ │ └── jwtToken.js
│ ├── Controllers
│ │ └── auth.controller.js
│ ├── Middleware
│ │ └── authMiddleware.js
│ ├── Models
│ │ └── user.model.js
│ ├── Routes
│ │ └── userRoutes.js
│ ├── Utils
│ │ └── sendEmail.js
│ ├── app.js
│ └── server.js
├── .env
├── .gitignore
├── package.json
├── README.md-
User Authentication
- Register User: POST /api/users/register
- Login User: POST /api/users/login
- Verify Email: GET /api/users/verify-email?token=your_verification_token
-
User Management
- Get All Users: GET /api/v1/users
- Get Single User: GET /api/v1/users/:id
- Update User: PUT /api/v1/users/:id
- Delete User: DELETE /api/v1/users/:id
- Block User: PUT /api/v1/users/block/:id
- Unblock User: PUT /api/v1/users/unblock/:id