Welcome to the Node.js E-commerce Project repository! This project is a simple e-commerce application built with Node.js.
- Node.js E-commerce Project
This project is a basic e-commerce application built with Node.js. It provides functionality for managing products, placing orders, and processing payments.
To set up the project on your local machine, follow these steps:
-
Clone the repository to your local machine using the following command:
-
Change into the project directory:
-
Install the required dependencies using npm:
npm install
-
Set up the environment variables. You will need to create a
.env
file in the root directory of the project and configure the following variables:PORT= # The port on which the server will run (default is 3000) DATABASE_URL=... # The URL of your MongoDB database JWT_SECRET=... # Secret key for JWT authentication
-
Start the server:
Once the server is running, you can access the e-commerce application by navigating to http://localhost:3000
in your web browser.
Here are the main endpoints and functionalities of the application:
- Description: Get a list of all users.
- Usage: This endpoint allows you to retrieve a list of all users registered in the system.
- Description: Get a user by ID.
- Usage: This endpoint allows you to retrieve a specific user's details based on their unique ID.
- Description: Register a new user.
- Usage: This endpoint allows users to register in the system. It requires a username, email, password, and optional image upload for the user profile.
- Description: Verify user registration and activate user account.
- Usage: This endpoint allows users to verify their registration by confirming their email address.
- Description: Delete a user by ID.
- Usage: This endpoint allows you to delete a specific user from the system based on their unique ID.
- Description: Update user by ID.
- Usage: This endpoint allows you to update a specific user's details based on their unique ID. It accepts new data, including an optional image upload for the user profile.
- Description: User login.
- Usage: This endpoint allows users to log in to the system. It requires a username/email and password for authentication.
- Description: User login.
- Usage: This endpoint allows users to log out from the system.
- Description: Create a new category.
- Usage: This endpoint allows you to create a new category in your e-commerce system. It is typically used to categorize products.
- Description: This middleware utilizes
multer
for handling file uploads, such as user profile images. - Usage: It intercepts requests that include file uploads and processes them, saving the files to the appropriate destination on the server.
- Description: This middleware checks if a user is logged in before allowing access to specific routes.
- Usage: It can be applied to routes that require authentication. If the user is authenticated, the middleware allows access; otherwise, it may redirect to a login page or return an appropriate error response.
- Description: This middleware checks if a user is logged out before allowing access to certain routes.
- Usage: It can be applied to routes that should only be accessible to non-logged-in users. If the user is not authenticated, the middleware allows access; otherwise, it may redirect to a different page or return an appropriate error response.
- Description: This middleware checks if a logged-in user has administrative privileges.
- Usage: It can be applied to routes that are restricted to administrators. If the user is an administrator, the middleware allows access; otherwise, it may redirect to a different page or return an appropriate error response.
Feel free to explore the codebase and customize the application to suit your needs!
We welcome contributions to this project. If you would like to contribute, please follow these steps:
- Fork the repository on GitHub.
- Create a new branch with a descriptive name for your feature/bug fix.
- Make your changes and commit them with a clear message.
- Push your changes to your forked repository.
- Create a pull request to merge your changes into the main repository.
This project is licensed under the MIT License.